I am building a react native app and I have google social connections enabled.
- In my app I am using ‘react-native-auth0’ to authorise users
- In my backend I need to have offline access to google for various google API integrations
In the native app I am authorising using:
const scopes =
'offline_access openid profile email open:wss-connection';
await authorize({
scope: scopes,
audience: 'https://mydomain/api',
additionalParameters: {
['access_type']: 'offline',
['connection_scope']:
'https://www.googleapis.com/auth/user.birthday.read,https://www.googleapis.com/auth/contacts.readonly,https://www.googleapis.com/auth/profile.emails.read',
},
With this i do receive both an access token and a refresh token on the native client.
On my backend I am using the Auth0 users api to get identity information:
https://${config.auth.AUTH_DOMAIN}/api/v2/users/${encodedUserId}
I need this call to return the user’s access and refresh tokens. I get the access token in the identifies array. It does NOT return the refresh token.
I CAN get the refresh token If I authorise (in the native app) using ['prompt']: 'consent',
… ie
await authorize({
scope: scopes,
audience: 'https://mydomain/api',
additionalParameters: {
['access_type']: 'offline',
['prompt']: 'consent', // <---- added this
['connection_scope']:
'https://www.googleapis.com/auth/user.birthday.read,https://www.googleapis.com/auth/contacts.readonly,https://www.googleapis.com/auth/profile.emails.read',
},
… However this results in the user being prompted once with Google’s consent screen and then an additional consent screen from Auth0. Both screens ask for the exact same consents including offline access.
This is a very poor and confusing user experience Why can’t i get the refresh token without using this additional prompt? Do i need to configure something on the console? Or do I need to do something else here? This feels like a pretty common use case.
Note there are so many articles here re refresh tokens that I think it should by now be clear that your docs are not clear enough. Many seem out of date, and it feels like a moving target.