我知道有很多類似的問題,'invalid_grant'是我們從google api獲得的唯一'答案',但它們都是舊的,或者討論不同的獲取方式到相同的消息。刷新OAuth2令牌時出現錯誤@ Google_CalendarServices(php)
奇怪的是,這個'東西'在2天前才停止工作。在我們的CRM中,我們將會議預訂到與GoogleAccount相關聯的GoogleCalendars中。現在在過去的兩天裏,我們遇到了問題,從未發生過。
申請失敗是這樣的:
Fatal error: Uncaught exception 'Google_AuthException' with message 'Error refreshing the OAuth2 token, message: '{"error" : "invalid_grant";} Stack trace: #0 /path/to/plugins/google-api-php-client/src/auth/Google_OAuth2.php(240): Google_OAuth2->refreshTokenRequest(Array) #1 /path/to/plugins/google-api-php-client/src/auth/Google_OAuth2.php(217): Google_OAuth2->refreshToken('1/ourtoken...') #2 /path/to/plugins/google-api-php-client/src/service/Google_ServiceResource.php(167): Google_OAuth2->sign(Object(Google_HttpRequest)) #3 /path/to/plugins/google-api-php-client/src/contrib/Google_CalendarService.php(494): Google_ServiceResource->__call('insert', Array)
這是實際的HTTP答案:
Google_HttpRequest Object ( [batchHeaders:Google_HttpRequest:private] => Array ( [Content-Type] => application/http [Content-Transfer-Encoding] => binary [MIME-Version] => 1.0 [Content-Length] => ) [url:protected] => https://accounts.google.com/o/oauth2/token [requestMethod:protected] => POST [requestHeaders:protected] => Array ( [content-type] => application/x-www-form-urlencoded [content-length] => 196 ) [postBody:protected] => client_id=111111111.apps.googleusercontent.com&client_secret=secretSECTRETsecretSECRET&refresh_token=1%2FveryLONGtokenSTRINGhafbuaADDFR&grant_type=refresh_token [userAgent:protected] => Google Calendar PHP Starter Application google-api-php-client/0.6.0 [responseHttpCode:protected] => 400 [responseHeaders:protected] => Array ( [content-type] => application/json; charset=utf-8 [cache-control] => no-cache, no-store, max-age=0, must-revalidate [pragma] => no-cache [expires] => Mon, 01 Jan 1990 00:00:00 GMT [date] => Thu, 10 Nov 2016 01:05:15 GMT [x-content-type-options] => nosniff [x-frame-options] => SAMEORIGIN [x-xss-protection] => 1; mode=block [server] => GSE [alt-svc] => quic=":443"; ma=2592000; v="36,35,34" [accept-ranges] => none [vary] => Accept-Encoding [transfer-encoding] => chunked ) [responseBody:protected] => { "error" : "invalid_grant" } [accessKey] => )
是的,我們使用的是舊版本,沒有任何新的東西。是的,帳戶是活的,我們試圖插入的日曆已存在。沒有權限或密碼被更改/重置。我們嘗試了所有的日曆 - 完全沒有成功。我也嘗試了一些小的改動/黑客,我發現這裏好像沒有使用開發者密鑰,設置訪問類型爲脫機,同步服務器時間等等...
其實我們什麼也沒做整個事情就壞了之前。所以有一個問題:Google是否改變了行爲/代碼或其他內容?或者我們錯過了某些東西(比如已棄用/已刪除的功能)?
編輯#1
我的一個學院做了改變,其實東西。 (更多關於編輯部分末尾的內容)
所以我們有一個'主'谷歌帳戶,機智開發人員密鑰和clientid和一切 - >和此帳戶也有1個日曆。
比我們的同事還有其他多個Google帳戶。我們從主日曆到日曆授予資金,反之亦然。在我們的CMS中,我們嘗試將一個事件(因此插入Google_CalendarService)添加到其中一個同事日曆中。
所以我們的一個同事辭職了,我的大學換了HIS密碼。並刪除了贈款。那麼它發生在週一16:00和週二早上我們得到了第一個錯誤。這一個Google帳戶的變化會影響所有其他人的行爲嗎?主日曆帳戶的行爲?
- 的編輯#結束1
如果有誰遇到過類似這樣的東西,並設法解決,請給一些建議。謝謝!
您是否使用其中一個Gmail範圍?用戶最近更改密碼的任何機會? 「Google改變了行爲/代碼或其他內容?」我不確定,但在過去幾周裏我看到了很多這樣的問題。我有一個谷歌聯繫人檢查它。 – DaImTo
嗨@DaImTo,謝謝你的評論。我們沒有明確定義任何範圍,我將編輯描述以給您更多關於使用情況的信息。從你的谷歌傢伙的反饋將是非常好的。歡呼聲 – solotherm
讓我更清楚。在對用戶進行身份驗證時,您至少必須要求Google日曆範圍。您是否請求任何其他權限? – DaImTo