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)