8

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?

1

3 Answers 3

12

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.

2

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

2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.