Joel Holmes
Joel Holmes

Reputation: 1053

Get Firebase Token for Backend Testing

I am writing an application in which I would like to use Firebase for the authentication of any sort of back end calls. Is there a way for me to get a token through a CLI or curl for local testing without having to spin up a front end to get the token?

Upvotes: 8

Views: 5421

Answers (3)

galecore
galecore

Reputation: 21

They changed the link - see REST API.

curl 'https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=[API_KEY]' \
-H 'Content-Type: application/json' \
--data-binary '{"email":"[[email protected]]","password":"[PASSWORD]","returnSecureToken":true}'

In the example above, you would replace [API_KEY] with the Web API Key of your Firebase project, [[email protected]] with the user's email and [PASSWORD] with the user's password.

Upvotes: 2

Aditya Joardar
Aditya Joardar

Reputation: 594

Well i have made a front end one page html to generate dummy firebase ID token for your application, in case anyone needs it

Firebase Token Generator

Upvotes: 3

Cheche
Cheche

Reputation: 1516

As a resume (to me and maybe others) from @James-Poag answer, use:

curl 'https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyPassword?key=[API_KEY]' \
-H 'Content-Type: application/json' \
--data-binary '{"email":"[[email protected]]","password":"[PASSWORD]","returnSecureToken":true}'

Where:

  • email (string): The email the user is signing in with.

  • password (string): The password for the account.

  • returnSecureToken (boolean): Whether or not to return an ID and refresh token. Should always be true.

The property idToken from response payload is the parameter you're looking for.

Upvotes: 12

Related Questions