KAH117 | 2024-01-29 09:42:38 UTC | #1
From the genesys web site
const client = platformClient.ApiClient.instance; client.loginImplicitGrant(clientId, redirectUri, { state: state }) .then((data) => { console.log(data); // Do authenticated things }) .catch((err) => { // Handle failure response console.log(err); });
From a console trace (with appropriate console.log statements) the "then/catch" is not run the first time. The first time this executes it causes a redirect (if successful) back to this page (assuming redirect=calling page). The web pages re-loads and runs a second time. It then runs the above statement a second time and this time because the user is authenticated(?), the "then" runs and returns a token and it sets this in "client".
Am I understanding this right?
Thanks
Jerome.Saint-Marc | 2024-01-29 10:00:29 UTC | #2
Hello,
That's correct. It is because, in an OAuth Implicit Grant flow, the user needs to be redirected to the Genesys Cloud login page (switch to a different page/url - if the user is not authenticated yet). On successful login, Genesys Cloud redirects the user (i.e. the web client) to the url provided as redirecturl, along with accesstoken or error information. The * loginImplicitGrant* method manages this, and exits on then/catch in this case.
Regards,
system | 2024-02-29 10:01:08 UTC | #3
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 24342