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?
-
1Try the REST API.– James PoagCommented Oct 26, 2018 at 15:54
3 Answers
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:
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.
Well i have made a front end one page html to generate dummy firebase ID token for your application, in case anyone needs it
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.