Closed Minotti closed 3 years ago
Without any code and/or examples it's hard for me to guess what might have gone wrong ๐ . The error states a base64 decode error - could you check if entering the token for example in an online base64 decoder, yields an error or not?
I don't know Firebase for Flutter enough, so I can't confirm nor deny that user.getIdToken()
returns a value ready to be transmitted, but if you would share the PHP code you're using to verify the ID token, I can at least confirm if that's looking alright ๐ค๐ผ
Well, this is my code, very simplistic, just for testing.
In anyone decoder base64 online I don't get an error.
If I try to give a base64_decode ($idToken) and stop for parseToken or verifyIdToken I get this message:
The given token could not be parsed: The JWT string must have two dots
I'll look into why the verifyIdToken()
method doesn't accept the output of parseToken()
, because it should.
In the meantime: you shouldn't need both methods, verifyIdToken()
also returns the parsed token, sonic you remove the parseToken()
call, it should work.
Code as a code block is always better than a screenshot (easier to copy and paste ๐ ).
However, I can't reproduce the error (here's the test I added trying to confirm the issue), but since you now shared the actual error you received, I can tell you that what you are using is a JWT, but not an ID token. ID tokens are always signed and the token you're providing is not (a simple JWT has a header and a payload, separated by one dot; a signed JWT has a header, a payload and a signature, separated by two dots).
You mentioned that you copied the token just to test it. A Google search led me to a comment describing the possible issue that print statements from Flutter could have been truncated(https://github.com/flutter/flutter/issues/31635#issuecomment-502790759) with a possible workaround by using debugPrint()
instead of print()
(https://stackoverflow.com/a/49156942/284325) or by using a helper method (https://github.com/flutter/flutter/issues/22665#issuecomment-458186456)
@jeromegamez Sorry for taking too long to answer. I will test it and I will return here.
@jeromegamez WooooooooooooooooooooooooW
(https://github.com/flutter/flutter/issues/31635) This work perfectly. Thank you so much man, you are awesome!
I'm glad it worked out ๐๐ผ
I made a test application just to get the idToken of my login in an application made in Flutter.
I copied the token and put it in the Controller just to test it, and I'm having this error.
Am I stupid? Is there a smarter way to test a flutter app with the backend?
Or is it really a mistake?
In Flutter id get token by
user.getIdToken()