2

I managed to use the REST APIs for Firebase Realtime database to write some data to my database but I'm doing with this with no authentication turned on.

curl -X PUT -d '{ "test": "blah" }' 'https://<project>.firebaseio.com/stuff.json'

I'm trying to change my auth rule to be

".write": "auth != null"

but I can't figure out how to generate an auth token to use in:

https://<project>.firebaseio.com/stuff.json?auth=<some token>

I'm doing this from a server, so I don't want to use a user's token.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
ajma
  • 12,106
  • 12
  • 71
  • 90
  • See https://firebase.google.com/docs/auth/admin/create-custom-tokens – Frank van Puffelen Nov 12 '16 at 15:52
  • I tried that already but I need an ID token, not a custom token. When I use a custom token, the server responds with an error saying: Expected an ID token, but was given a custom token. – ajma Nov 13 '16 at 06:55

1 Answers1

1

I ended up using the Database Secrets to get the REST api to work with auth.

Project Settings-> Sevice Accounts -> Database Secrets
ajma
  • 12,106
  • 12
  • 71
  • 90