Firebase Rest api for remote config
Asked Answered
J

3

1

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

Juxtaposition answered 9/4, 2017 at 9:3 Comment(0)
F
4

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)

Freddafreddi answered 9/4, 2017 at 14:47 Comment(2)
Hi @frank-van-puffelen, there is any news on this new feature? ThanksProtozoon
You might want to have a look at my answer @ProtozoonZoa
P
12

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:

  1. In the Firebase console, open Settings > Service Accounts.
  2. Click Generate New Private Key, and then Generate Key.
  3. 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)

Philipson answered 13/3, 2018 at 17:53 Comment(1)
I'm trying to use this API in order to retrieve the Remote Config in a Command-Line-Interface program written in Golang. Do I have to store the service_account.json file on the consumers computer and get a token each time I want to do a request? Because this would be very insecure.. or could I just request a token once and store in the source code of my CLI program?Pekoe
F
4

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)

Freddafreddi answered 9/4, 2017 at 14:47 Comment(2)
Hi @frank-van-puffelen, there is any news on this new feature? ThanksProtozoon
You might want to have a look at my answer @ProtozoonZoa
E
2

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!

Emanative answered 13/3, 2018 at 18:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.