Firebase Authenticator error: VerifyIdTokenAsync() expects an ID token, but was given a legacy custom token #6245
Replies: 2 comments 1 reply
-
I'm sorry, I'm not sure exactly what the problem is or what piece of software is having the problem, this lacks some precision in the details that would let me comment further |
Beta Was this translation helpful? Give feedback.
-
I apologize, but I'm still confused
I'm not aware of any product called "Firebase Authenticator". I assume you mean "we are using the auth module of react-native-firebase" ?
Calling whose API? Where? On device in react-native-firebase? In cloud functions using firebase-admin-sdk? Somewhere else?
I would normally assume you mean in react-native-firebase, on a mobile device, but you link to a firebase-admin-sdk doc. We don't support that, this repo is for the react-native bindings to firebase-ios-sdk and firebase-android-sdk. So I don't know if you are in the right place or not really, sorry
On what server? Using C#? I guess it's the Firebase Admin .NET SDK ? Again, we support react-native here, not .NET. I honestly did not even know there was a .NET admin SDK or that cloud functions supported it. It appears .NET is supported directly from the google cloud console and not officially by firebase if I understand correctly
You run what code exactly in what execution context exactly? A minimal reproduction would be interesting to see, which is part of the "how to ask" document I sent, as well as the general idea of specifying all the dependencies and versions and execution environment information necessary to think clearly about the problem
Exactly which firebase code in exactly which github repo? Could you provide perhaps a link to the exact lines of code you mention?
A web search seems to indicate that "wrong" might not be the correct word, but "different" might be the right word. Specifically: https://groups.google.com/g/firebase-talk/c/qcAqulTpZaM indicates there are a couple types of token, and it's just a different one.
No working project that I know of, and very difficult to give advice without understanding the use case and all the actual solution components in use. This may help: https://firebase.google.com/docs/auth/admin/verify-id-tokens Noting especially this:
|
Beta Was this translation helpful? Give feedback.
-
I have an application using Firebase Authenticator for user management. When calling the API, I need to verify if the user is authentic.
I have generated the token on Javascript as per below based on the documentation provided:
let accessToken = await firebase.auth().currentUser.getIdToken(true);
Source: googleDoc
Then in the server, using c#, the code below which fails:
FirebaseToken decodedToken = await FirebaseAuth.DefaultInstance.VerifyIdTokenAsync(accessToken);
I have got the error message below
"message": "VerifyIdTokenAsync() expects an ID token, but was given a legacy custom token."
I had gone deeper and started to dig into firebase code from Github and it seems to be failing in this condition. The token seems to be wrong from Javascript (client-side).
if (!this.IsEmulatorMode && string.IsNullOrEmpty(header.KeyId))
Do you have a working project or any advice on this?
Beta Was this translation helpful? Give feedback.
All reactions