How to read the "extras" paramater within a JWT Token - get more information

Hi,
When signing in with an email address, I am trying to extract more information from a JWT token than just the token.

I also hope to receive the userID and other user details with the token response. I have Xano sending the token and I have the ability to add more “extras” data to the token as shown below. I have ability to add any extra information there from what I see.
T2

In Weweb, I can see the clean Token but it only has the authToken parameter available as shown below.
T1

Am I right the extras information is embedded within the Token?
I am struggling to extract this “extras” JSON information as it should be embedded somewhere in the response?

Or I might just make a second call to Xano to receive the user details based on the Token, which also works fine. I was trying to remove one of these steps if possible.

Hi

It depends of the method used to encode the token. You can try to decode it on a online tool like this one and see if it contains the metadata you need => https://jwt.io/

I think we should add a formula or a workflow action to decode JWT tokens :thinking:

@Alexis any update on this formula?

Hi, I think it was not prioritised since, I will add it in the roadmap :slight_smile:

In the meantime you could try to paste this inside a global formula named Parse JWT

const base64Url = token.split('.')[1];
const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
const jsonPayload = decodeURIComponent(window.atob(base64).split('').map(function(c) {
    return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));

return JSON.parse(jsonPayload);
2 Likes