I had a web application using OAuth2.0 as the login framework. However, after the users login for a period, like 1 hour, the application actually gives the error :
"PHP Fatal error: Uncaught exception 'Google_AuthException' with message '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.' in /home2/iaapro/public_html/test_app/google-api-php-client/src/auth/Google_OAuth2.php:221"
The fatal error tells that refresh token is not there. When I read the OAuth2.0 guide by Google, it's said the user will receive the access token and refresh token at the same time if the access type="offline" which is what I did.
When I got the fatal error, I just need to clear my browser cache and cookies and it works again.
I see somebody says that the access token and refresh token will be available as long as user doesn't revoke the access on his account. In my case, it expired in one hour even I didn't do so.
I can't find much information about this on Google. Can anyone explain to me or suggest me some useful reference ?
If we need to store the refresh token in database, is there any tutorial available ?
Thanks.