Detection of revoked permission for an application in the Google API

I am using the Google PHP client library. I successfully receive the token and update the token from the / google user for use with the API. As soon as the user cancels the permission for my site in the Google settings on the Google page, I get the following error:

Error calling GET https://www.googleapis.com/calendar/v3/users/me/calendarList: (401) Invalid Credentials

This is an expected behavior as the user revoked my permission. However, how do you determine if the user has canceled this access?

I am currently doing the following to find out if I have access:

//$token json fetched from database
$gclient->setAccessToken($token);
if ($gclient->getAccessToken())
    //i should have access

Well, this code, unfortunately, does not detect the revoked permission. How can I handle this?

+3
source share
2 answers

API Google 401 - . , 401 , .

, , API? Google push-, . , , , - API 401 .

0

, , .

, : , ,

  • API access_token 401.

    {
      "error": {
        "errors": [
          {
            "domain": "global",
            "reason": "authError",
            "message": "Invalid Credentials",
            "locationType": "header",
            "location": "Authorization"
          }
        ],
        "code": 401,
        "message": "Invalid Credentials"
      }
    }
    
  • 400 invalid_grant. RFC 6749, 5.2

    invalid_grant (,                , )                , , ,                URI,                 .

    :

    {
       "error" : "invalid_grant"
    }
    
+2

All Articles