5
votes

I followed the steps described here : https://firebase.google.com/docs/auth/admin/create-custom-tokens

I am able to create custom tokens using the Firebase Admin SDK.

I send them back to the client iOS app to use like this :

Auth.auth().signIn(withCustomToken: customToken ?? "") { (user, error) in
  // ...
}

But I get this error :

Code=17000 "The custom token format is incorrect. Please check the documentation." UserInfo={NSLocalizedDescription=The custom token format is incorrect. Please check the documentation., error_name=ERROR_INVALID_CUSTOM_TOKEN}

I'm using Firebase Admin 5.2.0 and the Firebase iOS client 4.0.0

Any idea?

2
Check this post for how to debug this: stackoverflow.com/questions/45110441/… Keep in mind the custom token lifetime is limited and it could expire if you are storing and reusing it.bojeil
I already managed to request newer one if it's expired, but my issue is that the token never worksMonta
Ok, wanted to get that out of the way. Check the decoded format of the custom token as described in that link.bojeil
@bojeil The token is correctly decoded with the correct data using the debugger jwt.ioMonta
Make sure the client side project matches the service account that generated that custom token. Try sending the token with the REST API: firebase.google.com/docs/reference/rest/auth/… If that doesn't help, you should contact Firebase Support.bojeil

2 Answers

0
votes

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.

0
votes

After checking the token and its lifetime, it turned out that a mismatch in system-time was the problem in our case.

After setting the timezone and the time to 'automatic', the problem was solved.