Authentication loginImplicitGrant is it really run twice

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

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 redirect_url, along with access_token or error information. The * loginImplicitGrant* method manages this, and exits on then/catch in this case.

Regards,

1 Like

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.