简体   繁体   English

Firebase Remote Config REST 授权错误

[英]Firebase Remote Config REST authorization error

I am using a python script to get my firebase remote config data as a json file.我正在使用python 脚本将我的 firebase 远程配置数据作为 json 文件获取。 My problem is that after I setup my service account , I still get the authorization error.我的问题是,在设置服务帐户后,我仍然收到授权错误。 My service account's role is already set to "Firebase Remote Config Admin".我的服务帐户的角色已设置为“Firebase Remote Config Admin”。 Even as "Owner", I still get the authorization error.即使作为“所有者”,我仍然会收到授权错误。

{
  "error": {
    "code": 403,
    "message": "[AUTHORIZATION_ERROR]: User does not have the following permission: GET_TEMPLATE",
    "status": "PERMISSION_DENIED"
  }
}

Any suggestions on what to check get through authorization?关于通过授权检查什么的任何建议?

Basically service accounts for firebase and google storage are different. firebase 和 google 存储的服务帐户基本上是不同的。

If you try to get template using normal service account you will fail如果您尝试使用普通服务帐户获取模板,您将失败

So you have to generate a firebase service account by following the below steps因此,您必须按照以下步骤生成 firebase 服务帐户

To generate a private key file for your service account:

In the Firebase console, open Settings > Service Accounts.

Click Generate New Private Key, then confirm by clicking Generate Key.

Securely store the JSON file containing the key.

More details can be found in this link: https://firebase.google.com/docs/remote-config/automate-rc#get_an_access_token_to_authenticate_and_authorize_api_requests可以在此链接中找到更多详细信息: https : //firebase.google.com/docs/remote-config/automate-rc#get_an_access_token_to_authenticate_and_authorize_api_requests

In short, to setup the firebase service account go to an url like below (replace your_project_name)简而言之,要设置 firebase 服务帐户,请转到如下所示的网址(替换 your_project_name)

https://console.firebase.google.com/project/your_project_name/settings/serviceaccounts/adminsdk https://console.firebase.google.com/project/your_project_name/settings/serviceaccounts/adminsdk

Hope this helps someone.希望这可以帮助某人。

I've encountered this issue myself and my foreshadowing is: the service accounts are not what they seem.我自己也遇到过这个问题,我的伏笔是:服务账户不是他们看起来的那样。 This 403 error when you are sure your service account has the correct permissions generally means your code is not using the account you think it is.当您确定您的服务帐户具有正确的权限时,此 403 错误通常意味着您的代码没有使用您认为的帐户。 In my case, even when specifying the credentials to use in the code, Firebase was still using the 'App Engine default service account'.就我而言,即使在代码中指定要使用的凭据时,Firebase 仍在使用“App Engine 默认服务帐户”。 Adding the required permissions to the App Engine default service account resolved this issue for me.向 App Engine 默认服务帐户添加所需的权限为我解决了这个问题。 For more information see: https://stackoverflow.com/a/71698105/2076025有关详细信息,请参阅: https://stackoverflow.com/a/71698105/2076025

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM