react-native-pure-jwt
react-native-pure-jwt copied to clipboard
Different tokens on iOS and Android from same payload.
Hello. Thank you for the library. I am having an issue, though I do not believe it is a bug. I am running into authentication issue when running my app on Android. The request authenticates correctly for iOS. I notice that the token returned from jwt.sign() is different on each platform, even when the payload body, secret key, and Hash Algo are identical. Is there a way to have the jwt.sign() function return the same token on both platforms?
Let me know if you need any more information.
Thank you!
Hey, @mattvaldez! Thanks for opening this issue!
Have you tried to decode the token to see if the information really isn't the same?
I'm not sure it's a problem to have two different strings if their decoded content is equal and it's properly signed. Are you facing issues with the tokens?
It would be helpful if you could drop some information about your environment, including the React Native version.
I'm also having the same issue. I'm using React Native version 0.63.2
Hello, I have a similar problem. I 'm using React Native version 0.63.4. Thanks everyone from now. I sign my token with code below. Sign
const signApiToken = async (userEmail) => {
const hashedMail = encrypt(userEmail);
var apiToken = await jwt.sign(
{
iss: hashedMail,
exp: new Date().getTime() + 3600 * 1000,
additional: '',
},
Config.coreConfig.secretKey,
{
alg: 'HS256',
},
);
return apiToken;
};
when i do this with my android device i got output below. eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ7aXY9OTViNGNjYWQzZjVmMjEwYzJhZDliYzA2YjEzYzA2ZjUsIGNvbnRlbnQ9Y2QxODM1NDJmMmE0OWQxOTlmMWM3ZTdlMzM3ODdjOWU1N2UxZTN9IiwiZXhwIjoxNjEzMzA5NzQxLCJhZGRpdGlvbmFsIjoiIn0.-N8GPG8bsmsmY2PKQuHCS-lE7xR4I40wtjo2WqORFv0 Decoded form
{
"iss": "{iv=95b4ccad3f5f210c2ad9bc06b13c06f5, content=cd183542f2a49d199f1c7e7e33787c9e57e1e3}",
"exp": 1613309741,
"additional": ""
}
when i try with ios similator i am getting output below. eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhZGRpdGlvbmFsIjoiIiwiaXNzIjp7ImNvbnRlbnQiOiJmNmRlYmY2MDZmN2E5Yzg3MGNiYWQ4YWUzNmFiZTcxYzc1ZTQyZSIsIml2IjoiNTExMGVjOTExYTkzMWQ4MjgxMzlhODk5NmZlNjBhODgifSwiZXhwIjoxNjEzMzA5ODU4fQ.Lbxx7PtiJvsc0z_ylx4cDfv4j17Tv251HPLd0en4zM0 Decode form
{
"additional": "",
"iss": { "content": "f6debf606f7a9c870cbad8ae36abe71c75e42e", "iv": "5110ec911a931d828139a8996fe60a88" },
"exp": 1613309858
}
Hi @ramazankanbur,
Could you please give me an example of hashedMail
content? Thanks.