[英]Google Drive API + Refresh Token + Multiple servers
我們正在使用此處描述的技術創建刷新令牌以使用 Google Drive 並將其存儲在配置設置中以用於production
獲得刷新令牌后,我們使用該庫中的 3 個項目client_id
、 secret_token
和refresh_token
將文件寫入 Google Drive,它在一台服務器上運行良好
一旦我們開始擁有多個服務器,我們就會收到身份驗證錯誤,我們懷疑這是因為這個refresh_token
在所有服務器(目前有 4 個服務器)上共享。
以前可能遇到過此問題的人的問題
client_id
、 secret_token
和refresh_token
?確切錯誤如下
[2021-01-24 00:01:40] production.ERROR: {
"error": {
"errors": [
{
"domain": "global",
"reason": "authError",
"message": "Invalid Credentials",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Invalid Credentials"
}
}
{"exception":"[object] (Google\Service\Exception(code: 401): {
\"error\": {
\"errors\": [
{
\"domain\": \"global\",
\"reason\": \"authError\",
\"message\": \"Invalid Credentials\",
\"locationType\": \"header\",
\"location\": \"Authorization\"
}
],
\"code\": 401,
\"message\": \"Invalid Credentials\"
}
}
at /var/www/projectname/php/vendor/google/apiclient/src/Http/REST.php:128)
[stacktrace]
#0 /var/www/projectname/php/vendor/google/apiclient/src/Http/REST.php(103): Google\Http\REST::decodeHttpResponse(Object(GuzzleHttp\Psr7\Response), Object(GuzzleHttp\Psr7\Request), 'Google_Service_...')
#1 [internal function]: Google\Http\REST::doExecute(Object(GuzzleHttp\Client), Object(GuzzleHttp\Psr7\Request), 'Google_Service_...')
從我們的測試來看,您似乎無法在多個服務器之間共享刷新令牌。 我們使用了相同的 client_id 和相同的 client_secret 並為每台服務器創建了一個 refresh_token,“無效憑據”錯誤消失了。
因此,如果您使用上面的“交換令牌的授權代碼”方法進行身份驗證,那么這似乎是上述過程的解決方案
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.