我在PHP中使用谷歌驅動器API。首先,我請求一個Auth URL並將用戶發送到該URL。按照預期,用戶授權並將其重定向到我的url,並在查詢字符串中包含授權碼。接下來,我打電話$client->authorize()
並從查詢字符串中傳入代碼。我得到以下錯誤:Google驅動器php API授權失敗,出現無效授權
Uncaught exception 'Google_AuthException' with message 'Error fetching OAuth2 access token, message: 'invalid_grant'' in
/home/a5874817/public_html/custom/google/src/auth/Google_OAuth2.php:113
Stack trace:
#0 /home/a5874817/public_html/custom/google/src/Google_Client.php(131): Google_OAuth2->authenticate(Array, '4/jN5JfD_ejozBj...')
#1 /home/a5874817/public_html/custom/docs_reply.php(10): Google_Client->authenticate('4/jN5JfD_ejozBj...')
#2 {main}
thrown in /home/a5874817/public_html/custom/google/src/auth/Google_OAuth2.php on line 113
這個帳戶已授權之前,這個應用程序,但驗證網址,始終包含ACCESS_TYPE =網上,並且它一個多小時前是如此的訪問令牌應該已經過期。什麼具體可能是這個錯誤的原因?
我不清醒,我交換授權代碼訪問令牌。我以後不想訪問,我提到了訪問類型,因爲我認爲它可能與我不瞭解的某些方面有關。 – Randomparanoid