Ajay
Ajay

Reputation: 115

Firebase CREDENTIAL for rest API

Firebase Rest API mentions that we can pass CREDENTIAL to provide access to authenticated nodes. However I was not able to find documentation on where I can find these credential or generate these credential. Custom tokens generated using NodeJS firebase-admin client also don't work.

https://firebase.google.com/docs/database/rest/save-data

https://docs-examples.firebaseio.com/rest/saving-data/auth-example.json?auth=CREDENTIAL

Upvotes: 1

Views: 1462

Answers (1)

vzsg
vzsg

Reputation: 2896

If you scrolled down a little on the same page, you would find the answer:

In the following example we send a POST request with an auth parameter, where CREDENTIAL is either our Firebase app secret or an authentication token...

  • Firebase secrets are legacy credentials you can find/create under Project settings - Service Accounts in the Console. Using one as the auth parameter gives the caller administrative access.
  • Or you can use a service account to generate admin level access tokens instead of relying on the legacy secrets. See here for the Java implementation.
  • Or if you have an authenticated user – for example you're implementing an API a client apps call via HTTP, passing along their current access token –, you can use that token directly to impersonate the user.

The custom authentication tokens serve a completely different purpose and are part of a different sign in flow. Therefore they do nothing via the REST API.

Upvotes: 1

Related Questions