venveo / craft-oauthclient

A free to use OAuth 2.0 Client helper for Craft 3 developers
MIT License
9 stars 3 forks source link

Cannot refresh access tokens #31

Closed piotrpog closed 4 years ago

piotrpog commented 4 years ago

I use plugin with google oauth. Not sure if it is problem with plugin, or I do something wrong on google end, but i cannot refresh access token, for example using CLI or by calling refreshToken() function directly.

I also noticed that each token has refreshToken property set to null.

Mosnar commented 4 years ago

@piotrpog This is actually more of a weird quirk with Google OAuth than a bug. If you don't request the token with "offline" permissions the very first time you authenticate, you will never receive a refresh token. The only way to get a refresh token after that is for the user to de-authorize the app in their Google settings.

You may be able to accomplish it by also forcing a re-prompt.

Take a look at this example: https://github.com/venveo/craft-oauthclient#example-1-modifying-the-oauth-provider-settings

Also related: https://stackoverflow.com/questions/10827920/not-receiving-google-oauth-refresh-token

piotrpog commented 4 years ago

thanks for fast reply. i will test it tomorrow. btw, i think this info should be in readme :)