Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library is not returning a valid RefreshToken #28

Closed
ghost opened this issue Jan 25, 2014 · 4 comments
Closed

Library is not returning a valid RefreshToken #28

ghost opened this issue Jan 25, 2014 · 4 comments

Comments

@ghost
Copy link

ghost commented Jan 25, 2014

I'd receiving a valid accessToken, however the refreshToken is undefined!

I have no clue how to debug it. Any help? :)

@bachp
Copy link

bachp commented Jan 27, 2014

Google does only return an refreshToken if offline access was requested [1]. You can tell passport to request offline access by adding accessType: 'offline' to the options passed to authenticate.

e.g. app.get('/auth/google', passport.authenticate('google', { accessType: 'offline' }));

Please also not that Google only gives you a refreshToken the first time a user approves your application.
To get a refresh token again you need to force Google to display the consent screen again. This can be done by passing approval_prompt: 'force' to the authenticate options.

I hope this helps.

[1] https://developers.google.com/accounts/docs/OAuth2WebServer#offline

@ghost
Copy link
Author

ghost commented Jan 30, 2014

I do have accessType: 'offline' setup.
Also, the approval_prompt: 'force' is not working.

I cloned this repo, put up my credentials and ran the oauth2 code under examples/ with still no luck.
Is it possible that it has to do with my app registered on google's console? Are there permissions I should do there or something?

@bachp
Copy link

bachp commented Jan 30, 2014

Could you try to remove the authorization for the app in your google account.
This way google will ask you for authorization again. In that case I received a refreshToken.

You can revoke the authorization here: https://security.google.com/settings/security/permissions

@ghost
Copy link
Author

ghost commented Jan 30, 2014

Ah... so @jaredhanson has a different naming convention, it should be approvalPrompt with no underscore.

@jaredhanson this is kind-of misleading. Can we have all optiosn named like in the original google documentation

Now i'm getting a refresh token! Thanks :)

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant