Code Authorization from react application for sending DTMF tone

hello, We are working on doing code authorization from the react application and wondering if other teams are having or experience the issue before I don't believe it's a unique but common error. I am hoping the team has already developed or adapted different alternate solutions to achieve.

I am getting the below error when trying to get a token after getting code from PureCloud.

Access to XMLHttpRequest at 'https://login.usw2.pure.cloud/oauth/token' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Any working example or codebase would be really appreciated.

The reason for doing the OAuth code authorization is sending the DTMF tone as it does not work with the client credentials type. please let me know if you are able to send DTMF with other credentials type (except code authorization)?

Hello,

From what I remember, sending a DTMF tone requires the user (who sends the API request) to be an active participant of the call.
Which also means that the token must be obtained with a grant type related to a user context - I mean Implicit Grant, Authorization Code Grant or SAML Bearer token.

Something I may not understand properly is what you are trying to do with code authorization.
The error seems to indicate that you are trying to send the request from your web client directly (web browser).
If it is the case, this would explain the error.
In an Authorization Code Grant flow, the token would typically be requested from a server (after receiving a code from the web cient).

If you want to use an Authorization Code grant, it means the web client will get a code first from Genesys Cloud (after the authentication).
The web client will then pass the code to a server side application - the server will then be able to request a token from Genesys.
You can see the related tutorial here.

If what you are trying to implement does not require a server to know the token (I mean that you are just trying to send the request from a web client/client side), then, you should use an Implicit Grant flow.
Define an OAuth client with type Token Implicit Grant.
Then, in your code, you can trigger the flow via the loginImplicitGrant method of the Genesys Cloud Javascript SDK.
You can see this tutorial as an example - step 3.

Regards,

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