I decode a jwt token with jwt-decode in my react app but i can not get claims parameter from that how can i get those? for example i gonna get role from claims params
this is my decode token result :
{
aud: "SampleAudience"
exp: 1564989998
"http://schemas.microsoft.com/ws/2008/06/identity/claims/role": "SuperAdministrators"
"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress": "sso_khani"
"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name": "sso_khani"
"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier": "ab57e777-91b6-4c4e-d709-08d715866555"
iss: "threenine.co.uk"
}
You can ask your back-end team to provide values in a defined key names. Still you can do,
Object.keys(decodedObj).forEach(function (key) {
let res = key.split("/");
if (res.length > 1) {
if (res[length - 1] === 'role') {
// decodedObj[key] will be your role
}
// here you will get role, emailaddress, name, nameidentifier
}
});
Let me know if this helps.