2016-11-17 65 views
0

我需要通過HTTP訪問我的FireBase數據庫,我不知道我應該在JWT聲明集的scope字段中插入什麼內容。在文檔中,它顯示「範圍:應用程序請求的權限的空格分隔列表」。 Firebase中我的數據庫的路徑就像https://console.firebase.google.com/project/fir-19f8e/database/data這是我應該輸入的範圍嗎?創建JWT訪問Google API需要哪些範圍?

let jwtClaimSet = 
["iss":"[email protected]", 
"scope":"", 
"aud": "https://www.googleapis.com/oauth2/v4/token", 
"exp": "", 
"iat": ""] 

enter image description here

回答

3

您需要以下範圍:

  • "https://www.googleapis.com/auth/firebase.database"
  • "https://www.googleapis.com/auth/userinfo.email"

您可以瞭解更多的Firebase Database REST API User Authentication文檔。

+0

任何想調用google API的人都可以找到如何製作JWT並簽名的完整說明。此外,如果你得到錯誤無效簽名,不受支持的grant_type,[這裏是答案。它只是工作](http://stackoverflow.com/questions/40696026/swiftvapor-requesting-oauth-token-for-service-account-with-error-unsupported-gr) – bibscy

+0

當我嘗試訪問Firebase數據庫,我得到錯誤權限被拒絕。 [我在這裏發佈的問題](http://stackoverflow.com/questions/40810233)。我感謝您的幫助。 – bibscy

+0

當我們只想使用從OAuth2.0服務器接收到的訪問令牌讀取/寫入Firebase數據庫時,爲什麼有必要向scopes參數賦予值「https:// www.googleapis.com/auth/userinfo.email」?我認爲'https:// www.googleapis.com/auth/firebase.database'將是唯一需要的範圍。 – bibscy