Google OAuth Refresh Token Expires After 1 Hour (PHP Google Ads API with Laravel)
My Google OAuth refresh token expires after one hour, even though both my OAuth and Google Ads API applications are verified and approved.
- Both OAuth and Google Ads API apps are verified and approved.
- Created a new client_credentials.json file after approval.
- Using the provided Laravel example for the PHP Google Ads API.
- Added the developer token with basic access and populated clientId and clientSecret in the google_ads_php.ini file.
For the refresh token i used command ~/go/bin/oauth2l fetch --credentials CLIENT_SECRET.json --scope adwords to obtain a refresh token. And added this token to google_ads_php.ini too.
Despite these steps, I consistently encounter a "token has been expired or revoked" error after 60 minutes.
This is standard oauth practice access tokens expire after one hour. Its up to the developer to use a refresh token request a new access token when the access token expires.
$client->fetchAccessTokenWithRefreshToken($client->getRefreshToken());