I am new to Genesys API and I am trying to access Genesys UserAPI using Javascript code but it is not letting me authenticate and I am getting any clue to get access token for it. Please help here.
I am using below login method and passing client id and secret key configured on oAuth.
client.loginClientCredentialsGrant(clientid,secretcode)
getting below error. I am following the steps mentioned in the JavaScript SDK document.
Error: The client credentials grant is not supported in a browser.
Client credential grants are meant to be used only for server side applications and non-user-based applications. Our SDKs do not allow a Client Credential grant to be used inside of the browser. Instead, you want to use an Implicit Grant. An implicit grant will force the user to authenticate through Genesys Cloud and then callback into an endpoint you provide with the token. From there, you will have a token to make API calls inside the browser.
Thanks,
John Carnell
Director, Developer Engagement
OK, Thanks let me try this....and get back in case any issue.
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);
});
i have created oAuth in Genesys but there is no detail for redirectUri and state..... Given example in SDK document is not very clear. Do have any working example code for ImplicitGrant in JavaScript/Node.js? If yes, please provide that.