Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[auth-emulator] Cannot provide API key in header #5249

Closed
rhodgkins opened this issue Nov 16, 2022 · 0 comments · Fixed by #5263
Closed

[auth-emulator] Cannot provide API key in header #5249

rhodgkins opened this issue Nov 16, 2022 · 0 comments · Fixed by #5263
Assignees

Comments

@rhodgkins
Copy link
Contributor

[REQUIRED] Environment info

firebase-tools: 11.15.0

Platform: macOS

[REQUIRED] Test case

Start the emulator in auth only mode:

firebase emulator

[REQUIRED] Steps to reproduce

Following call succeeds with API key in the query parameters:
curl 'http://127.0.0.1:9099/identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key= EXAMPLE' -X POST -i -H 'content-type: application/json' --data-raw '{"email": "test@domain.com", "password": "password"}'

{
  "error": {
    "code": 400,
    "message": "EMAIL_NOT_FOUND",
    "errors": [
      {
        "message": "EMAIL_NOT_FOUND",
        "reason": "invalid",
        "domain": "global"
      }
    ]
  }
}

However trying the x-goog-api-key header it fails:
curl 'http://127.0.0.1:9099/identitytoolkit.googleapis.com/v1/accounts:signInWithPassword' -H 'x-goog-api-key: EXAMPLE' -X POST -i -H 'content-type: application/json' --data-raw '{"email": "test@domain.com", "password": "password"}'

{
  "error": {
    "code": 403,
    "message": "The request is missing a valid API key.",
    "errors": [
      {
        "message": "The request is missing a valid API key.",
        "reason": "forbidden",
        "domain": "global"
      }
    ],
    "status": "PERMISSION_DENIED"
  }
}

[REQUIRED] Expected behavior

For the API key provided in the header to work - see https://cloud.google.com/docs/authentication/api-keys#using-with-rest

[REQUIRED] Actual behavior

It doesn't and must be in the URL

@rhodgkins rhodgkins added the bug label Nov 16, 2022
yuchenshi added a commit that referenced this issue Dec 1, 2022
* Update Auth Emulator API spec.

* Add x-goog-api-key in API spec.

* Support x-goog-api-key in Auth Emulator. Fix #5249.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants