创建JWT访问Google API需要哪些范围?

问题描述:

我需要通过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

您需要以下范围:

  • "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://*.com/questions/40696026/swiftvapor-requesting-oauth-token-for-service-account-with-error-unsupported-gr) – bibscy

+0

当我尝试访问Firebase数据库,我得到错误权限被拒绝。 [我在这里发布的问题](http://*.com/questions/40810233)。我感谢您的帮助。 – bibscy

+0

当我们只想使用从OAuth2.0服务器接收到的访问令牌读取/写入Firebase数据库时,为什么有必要向scopes参数赋予值“https:// www.googleapis.com/auth/userinfo.email”?我认为'https:// www.googleapis.com/auth/firebase.database'将是唯一需要的范围。 – bibscy