Closed Harmew closed 1 month ago
i installed version @react-native-async-storage/async-storage@1.13.0 and not work
i found the error in /src/token/token.js
in this function
import { Base64 } from 'js-base64'
function base64DecodeStringUrlSafe(base64IdToken) { return decodeURIComponent(Base64.decode(base64IdToken)) }
i dont know why this Base64 cant decode the string, with i test in browser decode https://www.base64decode.org/
the same string works????
Hi, @Harmew I had the same problem, I went to react-native-azure-auth/src/token/token.js and found that the problem is in the library itself so I just changed it to the 'jwt-decode' instead of 'js-base64' and it works now.
import {jwtDecode} from 'jwt-decode'
export function extractIdToken(encodedIdToken) {
const decodedToken = jwtDecode(encodedIdToken)
console.log('decodedToken', decodedToken)
if (!decodedToken) {
return null
}
return decodedToken;
}
also, the library does everything for us, so I removed the remaining code
@VeljkoSkrbic thanks for your hint. Library updated.
I'm still receiving erors even after updating, I see that the library 'js-base64' is also being used in the baseTokenItem.js file, does this also require some changed with the other library 'jwt-decode'? @vmurin
I'm still receiving erors even after updating, I see that the library 'js-base64' is also being used in the baseTokenItem.js file, does this also require some changed with the other library 'jwt-decode'? @vmurin
Please post here a full stack trace of your error. Or some another info, that could help to analyse the issue.
I noticed it works on some cases, but maybe after the tokens are saved in the cache and received from it, there might be the issue @vmurin
@QendresaB-OM Please look at the screenshot above in this issue - in the stack trace there we can see the source files and code line numbers, so we could analyse the cause. Do you have the same from your issues?
When i login
i received this error
ERROR: The returned id_token could not be decoded [Error: Not a valid base64 encoded string length] LOG Error during Azure operation [TypeError: Cannot read property 'preferred_username' of null]
somebody can help me? or this is because the lib use @react-native-async-storage/async-storage@^1.23.1?