The-Monkeys-and-MAUD/laravel-google-auth

Token expiring and no refresh token

Opened this issue · 2 comments

So, I think when configuring the client with the 'offline' access type, Google requires the access token to be refreshed after the token expires. Have you come across the following error after being logged in for over an hour or so?

'The OAuth 2.0 access token has expired, and a refresh token is not available.
 Refresh tokens are not returned for responses that were auto-approved.'

I've implemented user registration in my application, so that after a user authenticates, some user data is stored in my database. Included in that stored data is the access token with a refresh token received upon the initial authentication. Do you know how I should go about implementing the 'refreshToken' function with your library? Or would you have a better idea? Maybe it would be easier and/or better to detect if the access token is expired, and then log the user out and back in again. By the way, I commented out "App::make('google-client')->revokeToken();" in the 'logout' function so that I don't have to make the user keep seeing the oauth 'consent' page.

I would like some help with this too.

Thank you

Don't actually store the access token. Store the refresh token and every time you make a call, hit the refresh token for an auth token. Then use that to make the call.