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

[feature request] Extensions Emulator should work when logged out #5510

Open
vajahath opened this issue Feb 12, 2023 · 2 comments
Open

[feature request] Extensions Emulator should work when logged out #5510

vajahath opened this issue Feb 12, 2023 · 2 comments

Comments

@vajahath
Copy link

[REQUIRED] Environment info

firebase-tools: 11.22.0

Platform: macOS

[REQUIRED] Steps to reproduce

  • start a demo- project. As per this doc

When working with demo Firebase projects, your apps and code interact with emulators only. If your app attempts to interact with a resource for which an emulator isn't running, that code will fail.

  • install some extensions
  • try to start emulator

[REQUIRED] Expected behavior

The emulator pulls the required code and start. (I expect I don't have to be signed in to start my demo project emulator.)

[REQUIRED] Actual behavior

<logged in state>

 *  Executing firebase emulators:start 

i  emulators: Starting emulators: auth, functions, firestore, hosting, pubsub, storage, extensions
i  emulators: Detected demo project ID "demo-xxx-dev-1", emulated services will use a demo configuration and attempts to access non-emulated services for this project will fail.
i  emulators: Shutting down emulators.

Error: Errors while reading 'extensions' in 'firebase.json'
- HTTP Error: 401, Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
- HTTP Error: 401, Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
- HTTP Error: 401, Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.

 *  The terminal process "/bin/zsh '-c', 'firebase emulators:start'" terminated with exit code: 1. 

<I logged out>

➜  firebase emulators:start        
⚠  emulators: You are not currently authenticated so some features may not work correctly. Please run firebase login to authenticate the CLI.
i  emulators: Starting emulators: auth, functions, firestore, hosting, pubsub, storage, extensions
i  emulators: Detected demo project ID "demo-xxx-dev-1", emulated services will use a demo configuration and attempts to access non-emulated services for this project will fail.
i  emulators: Shutting down emulators.

Error: Errors while reading 'extensions' in 'firebase.json'
- HTTP Error: 401, Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
- HTTP Error: 401, Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
- HTTP Error: 401, Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.

with --debug

firebase emulators:start --debug
[2023-02-12T18:58:34.333Z] Object ".extensions" in "firebase.json" has unknown property: {"additionalProperty":"firestore-typesense-search"}
[2023-02-12T18:58:34.335Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
Failed to authenticate, have you run firebase login?
⚠  emulators: You are not currently authenticated so some features may not work correctly. Please run firebase login to authenticate the CLI. 
[2023-02-12T18:58:34.377Z] java version "17.0.6" 2023-01-17 LTS

[2023-02-12T18:58:34.377Z] Java(TM) SE Runtime Environment (build 17.0.6+9-LTS-190)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.6+9-LTS-190, mixed mode, sharing)

[2023-02-12T18:58:34.379Z] Parsed Java major version: 17
i  emulators: Starting emulators: auth, functions, firestore, hosting, pubsub, storage, extensions {"metadata":{"emulator":{"name":"hub"},"message":"Starting emulators: auth, functions, firestore, hosting, pubsub, storage, extensions"}}
i  emulators: Detected demo project ID "demo-xxx-dev-1", emulated services will use a demo configuration and attempts to access non-emulated services for this project will fail. {"metadata":{"emulator":{"name":"hub"},"message":"Detected demo project ID \"demo-xxx-dev-1\", emulated services will use a demo configuration and attempts to access non-emulated services for this project will fail."}}
[2023-02-12T18:58:34.380Z] Successfully read params from firestore-typesense-search.env
[2023-02-12T18:58:34.381Z] Error: ENOENT: no such file or directory, open '/Users/vajahathahmed/projects/xxx/extensions/firestore-typesense-search.env.default'
[2023-02-12T18:58:34.381Z] Error: ENOENT: no such file or directory, open '/Users/vajahathahmed/projects/xxx/extensions/firestore-typesense-search.env.0'
[2023-02-12T18:58:34.381Z] Error: ENOENT: no such file or directory, open '/Users/vajahathahmed/projects/xxx/extensions/firestore-typesense-search.env.demo-xxx-dev-1'
[2023-02-12T18:58:34.381Z] Error: ENOENT: no such file or directory, open '/Users/vajahathahmed/projects/xxx/extensions/firestore-typesense-search.env.local'
[2023-02-12T18:58:34.382Z] > refreshing access token with scopes: []
[2023-02-12T18:58:34.382Z] >>> [apiv2][query] POST https://www.googleapis.com/oauth2/v3/token [none]
[2023-02-12T18:58:34.382Z] >>> [apiv2][body] POST https://www.googleapis.com/oauth2/v3/token [omitted]
[2023-02-12T18:58:34.559Z] <<< [apiv2][status] POST https://www.googleapis.com/oauth2/v3/token 400
[2023-02-12T18:58:34.559Z] <<< [apiv2][body] POST https://www.googleapis.com/oauth2/v3/token [omitted]
[2023-02-12T18:58:34.560Z] >>> [apiv2][query] GET https://firebaseextensions.googleapis.com/v1beta/publishers/typesense/extensions/firestore-typesense-search/versions filter=&showPrereleases=true&pageSize=100&pageToken=
[2023-02-12T18:58:35.893Z] <<< [apiv2][status] GET https://firebaseextensions.googleapis.com/v1beta/publishers/typesense/extensions/firestore-typesense-search/versions 401
[2023-02-12T18:58:35.894Z] <<< [apiv2][body] GET https://firebaseextensions.googleapis.com/v1beta/publishers/typesense/extensions/firestore-typesense-search/versions {"error":{"code":401,"message":"Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.","status":"UNAUTHENTICATED","details":[{"@type":"type.googleapis.com/google.rpc.ErrorInfo","reason":"CREDENTIALS_MISSING","domain":"googleapis.com","metadata":{"service":"firebaseextensions.googleapis.com","method":"google.firebase.extensions.v1beta.ExtensionsService.ListExtensionVersions"}}]}}
[2023-02-12T18:58:35.895Z] Got error reading extensions entry firestore-typesense-search,typesense/firestore-typesense-search@0.4.0: FirebaseError: HTTP Error: 401, Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
[2023-02-12T18:58:35.897Z] Successfully read params from typesense-blueprint.env
[2023-02-12T18:58:35.897Z] Error: ENOENT: no such file or directory, open '/Users/vajahathahmed/projects/xxx/extensions/typesense-blueprint.env.default'
[2023-02-12T18:58:35.897Z] Error: ENOENT: no such file or directory, open '/Users/vajahathahmed/projects/xxx/extensions/typesense-blueprint.env.0'
[2023-02-12T18:58:35.898Z] Error: ENOENT: no such file or directory, open '/Users/vajahathahmed/projects/xxx/extensions/typesense-blueprint.env.demo-xxx-dev-1'
[2023-02-12T18:58:35.898Z] Error: ENOENT: no such file or directory, open '/Users/vajahathahmed/projects/xxx/extensions/typesense-blueprint.env.local'
[2023-02-12T18:58:35.899Z] > refreshing access token with scopes: []
[2023-02-12T18:58:35.900Z] >>> [apiv2][query] POST https://www.googleapis.com/oauth2/v3/token [none]
[2023-02-12T18:58:35.900Z] >>> [apiv2][body] POST https://www.googleapis.com/oauth2/v3/token [omitted]
[2023-02-12T18:58:36.231Z] <<< [apiv2][status] POST https://www.googleapis.com/oauth2/v3/token 400
[2023-02-12T18:58:36.231Z] <<< [apiv2][body] POST https://www.googleapis.com/oauth2/v3/token [omitted]
[2023-02-12T18:58:36.231Z] >>> [apiv2][query] GET https://firebaseextensions.googleapis.com/v1beta/publishers/typesense/extensions/firestore-typesense-search/versions filter=&showPrereleases=true&pageSize=100&pageToken=
[2023-02-12T18:58:37.532Z] <<< [apiv2][status] GET https://firebaseextensions.googleapis.com/v1beta/publishers/typesense/extensions/firestore-typesense-search/versions 401
[2023-02-12T18:58:37.533Z] <<< [apiv2][body] GET https://firebaseextensions.googleapis.com/v1beta/publishers/typesense/extensions/firestore-typesense-search/versions {"error":{"code":401,"message":"Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.","status":"UNAUTHENTICATED","details":[{"@type":"type.googleapis.com/google.rpc.ErrorInfo","reason":"CREDENTIALS_MISSING","domain":"googleapis.com","metadata":{"service":"firebaseextensions.googleapis.com","method":"google.firebase.extensions.v1beta.ExtensionsService.ListExtensionVersions"}}]}}
[2023-02-12T18:58:37.533Z] Got error reading extensions entry typesense-blueprint,typesense/firestore-typesense-search@0.4.0: FirebaseError: HTTP Error: 401, Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
[2023-02-12T18:58:37.535Z] Successfully read params from typesense-brands.env
[2023-02-12T18:58:37.535Z] Error: ENOENT: no such file or directory, open '/Users/vajahathahmed/projects/xxx/extensions/typesense-brands.env.default'
[2023-02-12T18:58:37.535Z] Error: ENOENT: no such file or directory, open '/Users/vajahathahmed/projects/xxx/extensions/typesense-brands.env.0'
[2023-02-12T18:58:37.535Z] Error: ENOENT: no such file or directory, open '/Users/vajahathahmed/projects/xxx/extensions/typesense-brands.env.demo-xxx-dev-1'
[2023-02-12T18:58:37.536Z] Error: ENOENT: no such file or directory, open '/Users/vajahathahmed/projects/xxx/extensions/typesense-brands.env.local'
[2023-02-12T18:58:37.536Z] > refreshing access token with scopes: []
[2023-02-12T18:58:37.537Z] >>> [apiv2][query] POST https://www.googleapis.com/oauth2/v3/token [none]
[2023-02-12T18:58:37.537Z] >>> [apiv2][body] POST https://www.googleapis.com/oauth2/v3/token [omitted]
[2023-02-12T18:58:37.698Z] <<< [apiv2][status] POST https://www.googleapis.com/oauth2/v3/token 400
[2023-02-12T18:58:37.698Z] <<< [apiv2][body] POST https://www.googleapis.com/oauth2/v3/token [omitted]
[2023-02-12T18:58:37.698Z] >>> [apiv2][query] GET https://firebaseextensions.googleapis.com/v1beta/publishers/typesense/extensions/firestore-typesense-search/versions filter=&showPrereleases=true&pageSize=100&pageToken=
[2023-02-12T18:58:38.963Z] <<< [apiv2][status] GET https://firebaseextensions.googleapis.com/v1beta/publishers/typesense/extensions/firestore-typesense-search/versions 401
[2023-02-12T18:58:38.963Z] <<< [apiv2][body] GET https://firebaseextensions.googleapis.com/v1beta/publishers/typesense/extensions/firestore-typesense-search/versions {"error":{"code":401,"message":"Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.","status":"UNAUTHENTICATED","details":[{"@type":"type.googleapis.com/google.rpc.ErrorInfo","reason":"CREDENTIALS_MISSING","domain":"googleapis.com","metadata":{"service":"firebaseextensions.googleapis.com","method":"google.firebase.extensions.v1beta.ExtensionsService.ListExtensionVersions"}}]}}
[2023-02-12T18:58:38.963Z] Got error reading extensions entry typesense-brands,typesense/firestore-typesense-search@0.4.0: FirebaseError: HTTP Error: 401, Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
i  emulators: Shutting down emulators. {"metadata":{"emulator":{"name":"hub"},"message":"Shutting down emulators."}}

Error: Errors while reading 'extensions' in 'firebase.json'
- HTTP Error: 401, Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
- HTTP Error: 401, Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
- HTTP Error: 401, Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.

Having trouble? Try firebase [command] --help

When I relogin this issue fixes. But I expect for a demo project, I don't have to sign in and select a project from firebase cloud.

@google-oss-bot
Copy link
Contributor

This issue does not seem to follow the issue template. Make sure you provide all the required information.

@joehan
Copy link
Contributor

joehan commented Feb 14, 2023

Hye @vajahath , thanks for reporting this. This is actually working as expected right now - the GetExtensionVersion endpoint checks authentication, so it needs to be called as a signed in user, even if you are using a 'demo-*' project in the emulator.

I see how the docs are a little misleading here - they are correct that the code running inside the functions emulator won't be able to call production. However, even on a 'demo-' project, the Extension emulator needs to go download the code to run in the first place.

Renaming this and switching it to a feature request - however, I don't expect to be able to work on this any time soon.

@joehan joehan removed the type: bug label Feb 14, 2023
@joehan joehan changed the title demo- project fails to start when extensions are used due to HTTP 401s [feature request] Extensions Emulator should work when logged out Feb 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants