Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Auth Emulator email/password Sign In REST endpoint

I'm able to use this endpoint https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=[API-KEY] (found in these docs @ section Sign In With Email / Password) to sign in a Firebase Authentication user via an HTTP request.

Is there anyway to accomplish this on the Firebase Authentication Emulator - is there an emulator REST endpoint which will serve the same function?

When I run the auth emulator on port 9099 I've tried -
. http://localhost:9099/v1/accounts:signInWithPassword?key=[API-KEY]
. http://localhost:9099/emulator/v1/accounts:signInWithPassword?key=[API-KEY]
. http://identitytoolkit.localhost:9099/emulator/v1/accounts:signInWithPassword?key=[API-KEY]
. http://localhost:9099/identitytoolkit/v3/relyingparty/verifyPassword?key=[API-KEY]

But none work. Any ideas?

Here is the response I get for each of these requests -

{
    "error": {
        "code": 404,
        "message": "Not Found",
        "errors": [
            {
                "message": "Not Found",
                "reason": "notFound"
            }
        ],
        "status": "NOT_FOUND"
    }
}

EDIT: Also tried this: http://localhost:9099/identitytoolkit.googleapis.com/v1/projects/emulator-test-project-id/accounts?key=[API-KEY]

but get the response

{
    "error": {
        "code": 400,
        "message": "INSUFFICIENT_PERMISSION : Only authenticated requests can specify target_project_id.",
        "errors": [
            {
                "message": "INSUFFICIENT_PERMISSION : Only authenticated requests can specify target_project_id.",
                "reason": "invalid",
                "domain": "global"
            }
        ]
    }
}
like image 491
MikeG Avatar asked Feb 24 '21 00:02

MikeG


1 Answers

This one works -

http://localhost:[PORT]/identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=[API-KEY]

where API-KEY can be any string and 9099 is the PORT on which the auth emulator is running. For me it defaults to 9099 but you can configure this via your firebase.json (more details here)

like image 55
MikeG Avatar answered Oct 10 '22 04:10

MikeG