Custom token auth not working

2,544 views
Skip to first unread message

mat...@yusofleet.com

unread,
Aug 17, 2017, 11:08:37 AM8/17/17
to Firebase Google Group
Hi there,

I am trying to use a custom token to authenticate to firebase like this: 
firebase.auth().signInWithCustomToken(t)

With t being my JWT, which decodes to this:
{
  "iat": 1502976779,
  "exp": 1502980379,
  "uid": "7065",
  "displayName": "Test",
  "claims": {
    "user_type": "operator",
    "driver_id": null
  }
}

I keep getting this error:
{code"auth/invalid-custom-token"message"The custom token format is incorrect. Please check the documentation."}

I think it is a configuration issue as it stoppe working in integration environment but is still working in production.

I spent the last 3 hours trying to solve this, any help would be greatly appreciated.


Kato Richardson

unread,
Aug 17, 2017, 12:23:13 PM8/17/17
to Firebase Google Group
Hey Mathieu,

It looks like your token is missing `alg`, which should be set to `RS256`. Not sure if that will fix the problem, but might be a starting point.

Assuming that doesn't help, and that you're using a third party lib, you might also try creating one of these using the Firebase admin SDK and see if the results are any different. That would give us a starting point to investigate.

Lastly, note that you can't share service accounts between projects for the purposes of Authentication. So if you tried to add a service account from one project to another to use it for both, you might see unexpected results (although I think the error is different in that case).

☼, Kato


--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/88b197b4-a7e1-4782-9f22-dd049b5f944b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Kato Richardson | Developer Programs Eng | kato...@google.com | 775-235-8398

ישראל לבקיבקר

unread,
Jan 17, 2019, 10:23:50 AM1/17/19
to Firebase Google Group
I try a lot time to solve it.. and I found something interesting. The custom_toke end with "%3D%3D", this is not a valid, you need to replace is with "==".. and it will work good.



בתאריך יום חמישי, 17 באוגוסט 2017 בשעה 18:08:37 UTC+3, מאת mat...@yusofleet.com:

ישראל לבקיבקר

unread,
Jan 20, 2019, 12:09:23 AM1/20/19
to Firebase Google Group
your custom token end with '==' or something else? 

--
You received this message because you are subscribed to a topic in the Google Groups "Firebase Google Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/firebase-talk/inOTp2vMS-o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to firebase-tal...@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--

בברכה,

ישראל לבקיבקר
מייל - israel...@gmail.com
נייד - 058.711.6434

Reply all
Reply to author
Forward
0 new messages