Hi,
We are currently facing an issue, where Genesys oauthcodegrantjwtexchange call "https://api.mypurecloud.de/api/v2/webdeployments/token/oauthcodegrantjwtexchange" is throwing 401
"message": "Failed to identify user for token: bdfa8b008052d3dffae6f71c3cb15843 deploymentId: xxxx",
"code": "unauthorized",
"status": 401,
"contextId": "e8c816fd-93f0-433d-b507-d7ceb8965842",
"details": [],
"errors": []
This is after authentication-server returns 200 , with logs saying
Success Exchange Authorization Code for Access token
Kindly provide some logs so that we can investigate the issue.
Our sample code snippet:
const shouldParseResult = query.includes("code=") && query.includes("state=");
if (shouldParseResult) {
console.log("> Parsing redirect");
const urlParams = new URLSearchParams(query);
const authCode = urlParams.get('code');
if (authCode) {
console.log('Authorization code received:', authCode);
integrateGenesysAuth(authCode, getStoredCodeVerifier(), getStoredNonce());
} else {
console.error('Authorization code not found');
}
}
};
function integrateGenesysAuth(authCode, codeVerifier, nonce) {
(function () {
console.log('Initializing Genesys Plugin');
Genesys('registerPlugin', 'AuthProvider', (AuthProvider) => {
AuthProvider.registerCommand('getAuthCode', (e) => {
e.resolve({
authCode: authCode, // Authorization code obtained after the redirect
redirectUri: window.location.origin, // Redirect URI for token exchange
codeVerifier: codeVerifier, // Use the original codeVerifier
nonce: nonce,
maxAge: 36000
});
});
AuthProvider.registerCommand('signIn', (command) => {
console.log('signIn command triggered');
const data = {
authCode: authCode,
redirectUri: window.location.origin,
codeVerifier: codeVerifier, // Use the original codeVerifier
nonce: nonce,
maxAge: 36000
};
AuthProvider.publish('signedIn', data);
command.resolve(data);
});
AuthProvider.ready();
});
})();