Oha*_*rry 1 python firebase firebase-remote-config
试图找到一个服务器到服务器(最好是在 python 中),以连接 Firebase 远程配置。
操作:查看和编辑。
发现这个有用的点子,
它包含身份验证、数据库和存储,但不包含远程配置。
我可以将自己的添加到 pip,但我没有找到任何记录其余 api 的内容 Remote Config
Firebase 现在提供远程配置 REST API!
要使用此 API,您必须首先在Google API 控制台上启用它。选择您的项目,然后单击“启用”按钮。
然后您需要一个访问令牌来授权 API 请求。您可以通过 3 个步骤获取令牌:
使用Google API 客户端库在您的服务器上检索令牌:
def _get_access_token():
"""Retrieve a valid access token that can be used to authorize requests.
:return: Access token.
"""
var SCOPES = [
"https://www.googleapis.com/auth/firebase.remoteconfig"
];
credentials = ServiceAccountCredentials.from_json_keyfile_name(
'service-account.json', SCOPES)
access_token_info = credentials.get_access_token()
return access_token_info.access_token
Run Code Online (Sandbox Code Playgroud)
您现在可以使用 API 查看当前的远程配置设置。您可以使用以下命令执行此操作:
curl --compressed -i -D headers -H "Authorization: Bearer token" -X GET https://firebaseremoteconfig.googleapis.com/v1/projects/my-project-id/remoteConfig -o filename.json
Run Code Online (Sandbox Code Playgroud)
只需替换my-project-id为您的 Firebase 项目的 ID。您当前的远程配置设置将以 JSON 格式返回:
{
"parameters": [{
"key": "someKey",
"value_options": [{
"value": "Some value here"
}]
}, {
"key": "otherKey",
"value_options": [{
"value": "someOtherValueHere"
}]
}]
}
Run Code Online (Sandbox Code Playgroud)
获取 JSON 文件后,您可以对其进行编辑以更改配置,然后使用以下命令将其重新发送到 Firebase:
curl --compressed -i -H "Content-Type: application/json; UTF8" -H "If-Match: last-returned-etag" -H "Authorization: Bearer token" -X PUT https://firebaseremoteconfig.googleapis.com/v1/projects/my-project-id/remoteConfig -d @filename.json
Run Code Online (Sandbox Code Playgroud)
(再次替换my-project-id为您当前的 Firebase 项目 ID)
| 归档时间: |
|
| 查看次数: |
5506 次 |
| 最近记录: |