簡體   English   中英

Google Drive API + 刷新令牌 + 多台服務器

[英]Google Drive API + Refresh Token + Multiple servers

我們正在使用此處描述的技術創建刷新令牌以使用 Google Drive 並將其存儲在配置設置中以用於production

獲得刷新令牌后,我們使用該庫中的 3 個項目client_idsecret_tokenrefresh_token將文件寫入 Google Drive,它在一台服務器上運行良好

一旦我們開始擁有多個服務器,我們就會收到身份驗證錯誤,我們懷疑這是因為這個refresh_token在所有服務器(目前有 4 個服務器)上共享。

以前可能遇到過此問題的人的問題

  • 我們是否需要創建 4 組client_idsecret_tokenrefresh_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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM