Trying to find a server to server (preferably in python), to connect with Firebase remote config.
Actions: View and edits.
found this useful pip,
It contains the autentication, database and storage but not remote config.
I can add my own to the pip but I haven't found anything documenting the rest api to Remote Config
Update (2018-03-13): As Rosário points out, there is now a REST API that allows you to read and edit configurations.
There still is no API for web clients that works similarly to the iOS and Android clients.
My previous answer is below the fold.
There is no public REST API to connect to Firebase Remote Config at this time.
Also see: Firebase Remote Config feature for web app (after Firebase expansion)
Firebase now provides a Remote Config REST API!
In order to use this API, you must first enable it on the Google APIs Console. Select your project, and click on the "Enable" button.
Then you need an access token to authorize API Requests. You can get the token in 3 steps:
- In the Firebase console, open Settings > Service Accounts.
- Click Generate New Private Key, and then Generate Key.
- Securely store the JSON file containing the key
Retrieve the token on your server using the Google API Client Library:
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
View Current Configurations
You can now view your current Remote Config settings with the API. You can do this with the command:
curl --compressed -i -D headers -H "Authorization: Bearer token" -X GET https://firebaseremoteconfig.googleapis.com/v1/projects/my-project-id/remoteConfig -o filename.json
Just replace my-project-id
with the id of your Firebase Project. And your current Remote Config settings will be returned in a JSON format:
{
"parameters": [{
"key": "someKey",
"value_options": [{
"value": "Some value here"
}]
}, {
"key": "otherKey",
"value_options": [{
"value": "someOtherValueHere"
}]
}]
}
Edit Current Configurations
After getting the JSON file, you can edit it to change the configurations and then re-send it to Firebase using the command:
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
(Once again, replace my-project-id
with your current Firebase Project ID)
Good news! There is now a REST API available for you to communicate with the Remote Config service.
You can use this to either create your own custom front-ends for managing your remote config values, import Remote Config values from elsewhere, or add support to have your Remote Config values change dynamically, via something like server-to-server communication. Give it a try!
来源:https://stackoverflow.com/questions/43304938/firebase-rest-api-for-remote-config