googleapis / googleapis/google-api-php-client

Random 501 errors when refreshing token

Open
#2,276 3 comments 1 reaction 0 assignees View on GitHub
type: question
Dominant language
PHP
Stars
9.8k
Forks
3.5k
PR merge metrics
No merged PRs in 30d

Description

Starting on Wednesday June 8th, we are getting randomly 501 errors when trying to refresh tokens:
```json
{"error": {"code": 501, "status": "UNIMPLEMENTED", "message": "Operation is not implemented, or supported, or enabled."}}
```

Here is the code that generates this error:

```php
$client = new \Google_Client();
$client->setApplicationName(config('google.APP_NAME'));
$client->setClientId(config('google.CLIENT_ID'));
$client->setClientSecret(config('google.CLIENT_SECRET'));
$client->setAccessType('offline');

$client->setAccessToken(TOKEN);

if ($client->isAccessTokenExpired()) {
\Log::debug("access_token expired");
$refresh_token = $client->getRefreshToken();
$new_access = $client->fetchAccessTokenWithRefreshToken($refresh_token);

// $new_access sometimes returns this error {"error": {"code": 501, "status": "UNIMPLEMENTED", "message": "Operation is not implemented, or supported, or enabled."}}
}
```

When we manually connect again the Google account (which generates and stores a new refresh token), the accounts refreshes correctly, and then after a few refresh fails again with a 501 error

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.