我正在使用PHP Google客戶端庫。我成功地從用戶/谷歌獲得令牌和刷新令牌以用於API。 一旦用戶撤銷許可,我的網站在谷歌網頁上谷歌的設置我得到以下錯誤:在Google API中檢測應用程序的已撤銷權限
Error calling GET https://www.googleapis.com/calendar/v3/users/me/calendarList: (401) Invalid Credentials
這是預期的行爲,因爲用戶撤銷我的許可。 但是,如何檢測用戶是否已取消該訪問?
目前我做以下,看看我是否有機會獲得:
//$token json fetched from database
$gclient->setAccessToken($token);
if ($gclient->getAccessToken())
//i should have access
嗯,這代碼遺憾的是不檢測的撤銷許可。我該如何處理?
撤銷許可後,你會得到你試圖獲得的授權無效例外下一次訪問令牌。 – pinoyyid