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

createCustomToken generates invalid Token #16

Open
markbreuss opened this issue Dec 17, 2023 · 6 comments
Open

createCustomToken generates invalid Token #16

markbreuss opened this issue Dec 17, 2023 · 6 comments

Comments

@markbreuss
Copy link

When i send the token back to the client and trie the LoginWithToken method I get:
error: [firebase_auth/invalid-custom-token] The custom token format is incorrect. Please check the documentation.

If i paste the token into jwt.io i get the following warning (although I can see the correct payload of the token.
Warning: Looks like your JWT signature is not encoded correctly using base64url (https://tools.ietf.org/html/rfc4648#section-5). Note that padding ("=") must be omitted as per https://tools.ietf.org/html/rfc7515#section-2

I did double check that the projects match and got it to work with the python admin sdk.

Any Ideas?

Thanks Mark

@rrousselGit
Copy link
Collaborator

When i send the token back to the client and trie the LoginWithToken method I get:

What does that mean exactly?
Maybe some code samples would help here

@markbreuss
Copy link
Author

markbreuss commented Dec 17, 2023

Of course so my workflow is:

  1. HTTP Request to Dart Backend (DartFrog) to get the token

  2. On the Server Endpoint I have the following code to generate the token
    auth.createCustomToken(uid, developerClaims: {'role': 'm1_admin'});

  3. On the client I use the token I genereated in step 2 to sign in with the flutter client sdk:
    FirebaseAuth.instance.signInWithCustomToken(token);

This is where I get the error:
error: [firebase_auth/invalid-custom-token] The custom token format is incorrect. Please check the documentation.

@markbreuss markbreuss changed the title createCustoomToken generates invalid Token createCustomToken generates invalid Token Dec 17, 2023
@gildaswise
Copy link

gildaswise commented Jan 17, 2024

I'm also having this issue, I'm just using the createCustomToken without any claims and I can't use the token with the signInWithCustomToken endpoint. Same error about the formatting

@HeySreelal
Copy link

HeySreelal commented Feb 12, 2024

I think #23 fixes this issue. Worked fine for me when I tested a few hours ago.

@kosukesaigusa
Copy link

@rrousselGit

Hello!

In the following PR:

#23

the reproducible code sample about this issue is described, and I tried to solve it.

I would greatly appreciate if you have a look at the PR, as some time has passed.

Thank you!

@Fraa-124
Copy link

Are there any reasons why hasn't been merged yet? The PR changes are working fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants