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

bug: auth emulator returns invalid custom token error #712

Open
bnyat22 opened this issue Aug 2, 2022 · 6 comments
Open

bug: auth emulator returns invalid custom token error #712

bnyat22 opened this issue Aug 2, 2022 · 6 comments
Labels
bug Something isn't working

Comments

@bnyat22
Copy link

bnyat22 commented Aug 2, 2022

Describe the bug
When I want to login to firebase via this command cy.login(uid), I will get an error which is coming form firebase.
Error:
Firebase: The custom token format is incorrect. Please check the documentation. (auth/invalid-custom-token).

@balazsotakomaiya
Copy link

balazsotakomaiya commented Sep 5, 2022

+1 on this, works when using an actual firebase instance, does not when switching to an emulator

@SeraphicRav
Copy link

Hello !

I do not have such an error using the emulator but did you set both the code being tested and the test code to use the emulator ? I think I got the auth/invalid-custom-token error when forgetting to set one of them.

@BenAshbyGP
Copy link

BenAshbyGP commented Sep 15, 2022

I just ran into this same issue today with my unchanged login flow was working for around 2 hours then suddenly stopped working and has been this way for now over an hour - this is the error as shown in the Cypress test runner:

BEFORE ALL (FAILED)
1. logCreating custom token for login...
2. taskcreateCustomToken, Object{3}
(xhr)POST 400 https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyCustomToken?key=<redacted>

The custom token format is incorrect. Please check the documentation.

Because this error occurred during a before all hook we are skipping the remaining tests in the current suite: Account user tests

In my case we log in once and then store that session so we do not need to constantly log in as we were hitting firebase quotas, but at the start of each spec file we clear the stored sessions prior to logging in.

Any suggestions would be most welcome as we have been using this package for months without issue!

Cypress version 10.3 as well if that makes a difference as later versions have caused us issues with flaky tests - thanks!

@Tockra
Copy link

Tockra commented Oct 8, 2022

I observed the same behavior in my application. My host 127.0.0.1:3000 is connected with the emulator.
Even the manual access to the emulators firebase runs:

cy.callFirestore('add', 'test_hello_world', { some: 'value' });

But cy.login() leads to the above error message... So I can't really test my web application.

@prescottprue
Copy link
Owner

Haven't retested with the auth emulator recently, so I'll take a look back at this, thanks for the callout.

As mentioned, pointing to a hosted auth instance should work fine with RTDB and Firestore emulators - this is actually what myself and team members are still doing in tests for multiple applications

@prescottprue prescottprue changed the title Can't login firebase with an uid bug: auth emulator returns invalid custom token error Dec 30, 2022
@prescottprue prescottprue added the bug Something isn't working label Dec 30, 2022
@prescottprue
Copy link
Owner

Seems to be a similar issue here: #421

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants