Quick question, has anyone seen this weird error? with my React app’s auth flow. I’m trying to validate the JWT returned from the implicit grant flow before making calls to the Analytics API for Snowflake extraction. The token comes back fine, and the login works, but my custom validation middleware keeps rejecting it as invalid.
I’ve been using jwt-decode to inspect the payload. The structure looks correct, but the iss claim doesn’t match the expected https://api.mypurecloud.com. Instead, it’s pointing to a subdomain that shifts based on the user’s region. This is breaking my strict issuer validation logic. I know the implicit grant is technically deprecated for new apps, but we’re stuck with it for now due to legacy integration constraints.
Here is the decoded token payload I’m seeing:
{
"iss": "https://usw2.platform.mygen.com/oauth/token",
"sub": "user-id-12345",
"aud": "client-id-xyz",
"exp": 1678886400,
"iat": 1678882800,
"scope": "analytics:query:read"
}
My validation code looks like this:
const validateToken = (token) => {
try {
const decoded = jwtDecode(token);
const expectedIssuer = 'https://api.mypurecloud.com';
if (decoded.iss !== expectedIssuer) {
throw new Error('Issuer mismatch');
}
if (decoded.exp < Date.now() / 1000) {
throw new Error('Token expired');
}
return true;
} catch (error) {
console.error('Token validation failed:', error.message);
return false;
}
};
I’ve tried hardcoding the usw2.platform.mygen.com issuer, but that feels fragile. Is there a reliable way to resolve the correct issuer URL dynamically from the token or the initial login request? Or should I be fetching the JWKS endpoint from a different base URL to verify the signature? I don’t want to skip issuer validation entirely, but I need this pipeline to run without constant manual intervention. Any pointers on how to handle this dynamic issuer issue in a React environment?