Normally, if you have saved the first access token you recieved, it should contain a refresh token. If you use setAccessToken()
to tell your client about that access token, the PHP client will auto-refresh the access token if it has expired.
You can use the setTokenCallback()
method to grab and permanently save that new access token so it can be reused. Doco for setTokenCallback()
is here:
https://github.com/googleapis/google-api-php-client#updating-tokens
You could alternatively do a manual token refresh with the fetchAccessTokenWithRefreshToken()
method - a great, easy to follow, example is in the quickstart here (for Calendar API, but principles are the same):
https://developers.google.com/calendar/quickstart/php
Reading the quickstart should be a huge help to you in making sense of all if this!