Giter VIP home page Giter VIP logo

Comments (4)

bachp avatar bachp commented on August 15, 2024

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

from passport-google-oauth.

 avatar commented on August 15, 2024

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?

from passport-google-oauth.

bachp avatar bachp commented on August 15, 2024

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

from passport-google-oauth.

 avatar commented on August 15, 2024

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 :)

from passport-google-oauth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.