I have an Angular 1.5 app using the Auth0 Angular SDK. My goal is to do authentication on the Angular app and then do automated tasks on a user’s google calendar server side (Using node).
So far I have everything working as far as using a hosted ‘Lock’ screen to authenticate using either username/password or Google. I am also able to successfully fetch an ‘access_token’ from Google from an identity object in the identities array on the object returned from the userinfo endpoint.
What I cannot get working for the life of me is for Auth0 to populate a refresh_token as part of the identity object. As I understand it (I could be incorrect) - all you have to do is add ‘access_type=offline’ to the params within the auth object.
I have read all of these articles, forum posts and more:
https://auth0.com/docs/libraries/lock/v10/configuration#params-object
I then made this change to my hosted lock code (small snippet shown):
.....
……
**config.internalOptions.accessType = 'offline'**
var lock = new Auth0Lock(config.clientID, config.auth0Domain, {
auth: {
redirectUrl: config.callbackURL,
responseType: (config.internalOptions || {}).response_type ||
(config.callbackOnLocationHash ? 'token' : 'code'),
params: config.internalOptions,
},
…….
…….
I have also tried:
**config.internalOptions.access_type = 'offline'**
The end result is always the same. I get an identity object without a refresh_token like so:
identities:
[ { user_id: '?????????585401352',
provider: 'google-oauth2',
connection: 'google-oauth2',
isSocial: true,
access_token: '??????????????????????????????????????????????????wP_BeLT-lL7ATxPZl-FTU2gEM',
expires_in: 3600 } ],
I’ve been at this for days to no avail. It seems like Auth0 just refuses to put the result of the code exchange in the object for some reason. Contacted support and they asked me to read the above articles.
What else do I need to do or check to get the refresh_token populated within the google-oauth2 identity object?