dart_firebase_admin icon indicating copy to clipboard operation
dart_firebase_admin copied to clipboard

createCustomToken generates invalid Token

Open markbreuss opened this issue 1 year ago • 6 comments

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

markbreuss avatar Dec 17 '23 13:12 markbreuss

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

rrousselGit avatar Dec 17 '23 13:12 rrousselGit

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 avatar Dec 17 '23 14:12 markbreuss

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

gildaswise avatar Jan 17 '24 20:01 gildaswise

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

The0xArchitect avatar Feb 12 '24 15:02 The0xArchitect

@rrousselGit

Hello!

In the following PR:

https://github.com/invertase/dart_firebase_admin/pull/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!

kosukesaigusa avatar Feb 21 '24 12:02 kosukesaigusa

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

Fraa-124 avatar Mar 30 '24 10:03 Fraa-124

Should be fixed by the next release

rrousselGit avatar Mar 20 '25 11:03 rrousselGit