Good day,
I am using react-native-auth0
I would like to pass along some extra data, to be used in a server side action on Auth0.
In my react-native code, I am doing something like this:
const {authorize, getCredentials, user, clearSession, error} = useAuth0();
...
await authorize(
{
scope:
'openid profile offline_access enroll read:authenticators remove:authenticators',
audience: `https://${config.auth0.domain}/mfa/`,
user_metadata: {
invitationToken: 'MY_INVITE_TOKEN',
},
},
{
ephemeralSession: true,
},
);
But for some reason, user_metadata is not accable inside the Action, nor is it showing up in the logs.
How can I pass some client side data to the authorize flow (I need it for both Login and Signup)?
Thank you,
Franck
Hey there @fnadeau !
Happy to work on this together.
I would need a few details -
-
Can you please confirm you refer to this auth0 SDK?
Is there a compatibility between your appās React Native SDK version and the chosen auth0 SDK (can be checked in the Readme.md )
-
If Iām not mistaken the authorize method you shared here is to bring the user to the login page to authenticate. What Login page you use? Universal Login / New universal Login / embedded login?
-
Could share more information on the action youāre working on?
- what flow and trigger you refer to?
Thanks!
Hey Franck @fnadeau !
The issue you encounter here can be reduced to IdP not supporting the custom āuser_metadataā parameter in /authorize requests.
The parameter you would like to use (I assume) can be classified as āupstream parameterā which would be sent to IdP in /authorize requests.
Upstream parameters, with some limitations, have to be first set for specific connection (like for example Username-Password-Authentication) via the Management API to make them available for /authorize requests.
It works this way:
There is a preset list of fields that you can map your custom parameter with.
Once you choose the field, use it in your /authorize requests.
Example:
Updating connection with an upstream parameter:
curl --request PATCH \
--url 'https://{yourDomain}/api/v2/connections/specific_connection' \
--header 'authorization: Bearer {yourMgmtApiAccessToken}' \
--header 'content-type: application/json' \
--data '{
'options': {
'upstream_params': {
'screen_name': {
'alias': 'login_hint'
}
}
}
}'
Where: ālogin_hintā is a preset field, and āscreen_nameā is a custom parameter of your choice. Login_hint used in /authorize parameters will be passed as āscreen_nameā to Auth0.
I think you could try with this approach (a guidance with the list of available fields here). Please let me know if that works for you. Thanks!