Hello,
Thanks for your answer. I am able to get my token at the purecloud oauthcodegrantjwtexchange endpoint, however when I run a server with a barebones HTML page with only the Javascript needed to run the Messenger, I still have an Auth.authError event that is raised after I register a getAuthCode command with the Genesys function.
Here is the code that I use to load the messenger and run the auth. The messenger works and I can get messages in my queue if I turn off "Authentication" in the "Messenger configurations" so I don't think there is anything wrong in the config.
<body>
<script type="text/javascript">
(function (g, e, n, es, ys) {
g['_genesysJs'] = e;
g[e] = g[e] || function () {
(g[e].q = g[e].q || []).push(arguments)
};
g[e].t = 1 * new Date();
g[e].c = es;
ys = document.createElement('script'); ys.async = 1; ys.src = n; ys.charset = 'utf-8'; document.head.appendChild(ys);
})(window, 'Genesys', 'https://apps.mypurecloud.de/genesys-bootstrap/genesys.min.js', {
environment: 'prod-euc1',
deploymentId: 'b44<<REDACTED>>',
});
</script>
<script>
Genesys('registerPlugin', 'AuthProvider', (AuthProvider) => {
AuthProvider.registerCommand('getAuthCode', (e) => {
const urlParams = new URLSearchParams(window.location.search);
const authCode = urlParams.has('code') ? urlParams.get('code') : ""
const redirectUri = "http://localhost:5000/test.html";
console.log(`getAuthCode called, code: ${authCode}, redirectUri: ${redirectUri}`);
e.resolve({
authCode: authCode,
redirect_uri: redirectUri
})
});
AuthProvider.subscribe('Auth.ready', () => {
console.log("Auth plugin ready");
});
AuthProvider.subscribe('Auth.authenticated', (jwt,refreshToken) => {
console.log("Auth.authenticated");
});
AuthProvider.subscribe('Auth.authError', (e) => {
console.log("Auth.authError");
console.log(JSON.stringify(e, null, 4));
});
AuthProvider.ready();
});
</script>
</body>
In my Network tab, I have calls to get the "genesys.min.js" script and the "domains.json" and "config.json" file, but there isn't any call to the oauthcodegrantjwtexchange endpoint.
In my console logs, getAuthCode seems to be correctly called but I have the same error message
getAuthCode called, code: jOb<<REDACTED>>, redirectUri: http://localhost:5000/test.html
Auth plugin ready
Auth.authError
{
"time": 1712660824415,
"publisher": "Auth",
"event": "auth.autherror",
"eventName": "authError",
"data": {
"authCode": "jOb<<REDACTED>>",
"redirect_uri": "http://localhost:5000/test.html"
}
}
When I use this auth code with the same redirect_uri and deploymentId, I'm able to successfully get my tokens.
Thanks,