Genesys Cloud - Main

 View Only

Discussion Thread View
Expand all | Collapse all

Conversation API access issue

  • 1.  Conversation API access issue

    Posted 24 days ago

    I need to execute /api/v2/conversations/calls/${input.conversationId}/participants/${input.participantId}  API on button click in scripts.

    I created a data action with client credentials but getting error: "This request requires a user context. Client credentials cannot be used for requests to this resource"

    Can anybody help me how I can access this API in script?


    #API/Integrations

    ------------------------------
    Dimple Saggi
    ------------------------------


  • 2.  RE: Conversation API access issue

    Posted 23 days ago

    Hello Dimple. 

    For Data Actions, you will need to use Client Credentials specifically. The error is what's thrown if you are not using client credentials to execute a data action--so, I'm unsure why you would see the same error when configuring the integration to use an ouath client with that specific grant type.

     

    When using client credentials it's also important to make sure the oauth client has appropriate roles in the correct divisions as well.

     

    Could you provide me an image of the oauth client setup so I can examine for potential issues? Please be sure to scrub the client secret since that should stay secure.

     

    It's also important to note that for client credentials, user context is not taken into account, so it will not matter what permissions you have when running the data action. The data action will only be looking for authorization from the oauth client itself and what permissions it has.

    Cheers, 



    ------------------------------
    Cameron
    Online Community Manager/Moderator
    ------------------------------



  • 3.  RE: Conversation API access issue

    Posted 23 days ago
      |   view attached

    Hi Cameron,

    Thank you for your reply.

    Now as I know client credentials will not help me here so I had create Code Auth grant type as below pic.

    But no idea what should I mention in callback URI (we don't have any web server) so I was using these Client id & secret key to get authenticate to call  API  https://api.mypurecloud.com.au/api/v2/conversations/calls/8b639aee-1f36-400a-9f43-2dfba1002310/participants/2a596d69-eec9-40da-8562-83b5be511776. 

    But this also giving the same error. 

    Questions now 
    * which integration & data action types I need to use here?

    • what grant types need here?
    • If Code Authorization needed what will be redirect URI?



    ------------------------------
    Dimple Saggi
    ------------------------------



  • 4.  RE: Conversation API access issue

    Posted 21 days ago

    Hello Dimple,

    May I know your use case/what is your scenario on using this API? is there anything you want to update from the participants? just curios



    ------------------------------
    Ernest John Nuque
    ------------------------------



  • 5.  RE: Conversation API access issue

    Posted 11 days ago

    Hi Ernest,

    We want call the control button at the desktop which performs hold, transfer, unhold activities for active interaction.

    Thank you



    ------------------------------
    Dimple Saggi
    ------------------------------



  • 6.  RE: Conversation API access issue

    Posted 11 days ago

    Hi Dimple,

    I'm no expert, but my understanding is, most of the the conversation APIs are all user context based. Which is why client credentials won't work. Implicit Grant or code grant / PKCE should work - https://developer.genesys.cloud/authorization/platform-auth/use-pkce

    Take a look at some of these similar threads on the developer forum:

    https://developer.genesys.cloud/forum/t/error-this-request-requires-a-user-context/30455

    https://developer.genesys.cloud/forum/t/not-a-user-message-this-request-requires-a-user-context-client-credentials-cannot-be-used-for-requests-to-this-resource/570/4

    And some info on code auth flow - https://developer.genesys.cloud/authorization/platform-auth/guides/oauth-auth-code-guide



    ------------------------------
    Anton Vroon
    ------------------------------



  • 7.  RE: Conversation API access issue

    Posted 10 days ago
      |   view attached

    Thanks Anton,

    Is there any way I can get user login token in data actions?

    or 

    Can Call implicit flow auth code in embedded iframe, which not getting token though.

    Or any other way to get token so I can call conversation api at desktop when an interaction lands at desktop



    ------------------------------
    Dimple Saggi
    ------------------------------

    Attachment(s)

    html
    CallControls.html   4 KB 1 version


  • 8.  RE: Conversation API access issue

    Posted 10 days ago

    Hi,

    You can't get user context when using Data Actions.

    I would probably use an embedded web application in the script that uses Implicit Grant and calls the conversation APIs.



    ------------------------------
    Jan Heinonen
    Contact Center Specialist
    GlobalConnect AB
    ------------------------------



  • 9.  RE: Conversation API access issue

    Posted 9 days ago
      |   view attached

    Thanks Jan,

    I found one one script for interaction widget which can get user Token but SDK not loading

     <script src="https://apps.mypurecloud.com/developercenter-cdn/webrtc-sdk/4.1.1/genesys-cloud-webrtc-sdk.bundle.min.js"></script>

    any idea which sdk needed to get token

    if (window.purecloud && window.purecloud.user) {
                    // Attempt to retrieve the token
                    window.purecloud.user.getAuthToken()
                        .then(function(token) {
                            // Successfully retrieved the token
                            console.log('User Auth Token:', token);
                            // Call the Conversation API with the token
                            callConversationApi(token);
                        })
                        .catch(function(error) {
                            console.error('Error retrieving auth token:', error);
                        });
                } else {
                    console.error('Genesys Cloud SDK is not available');
                }



    ------------------------------
    Dimple Saggi
    ------------------------------

    Attachment(s)

    html
    EmbedIframe.html   2 KB 1 version


  • 10.  RE: Conversation API access issue

    Posted 10 days ago

    Again not my specialty, but I imagine your web app that you are embedding there should be doing the authentication, not a data action doing it.

    You may want to check out the developer forum https://developer.genesys.cloud/forum/ for more technical questions



    ------------------------------
    Anton Vroon
    ------------------------------



  • 11.  RE: Conversation API access issue

    Posted 9 days ago

    Thanks Anton



    ------------------------------
    Dimple Saggi
    ------------------------------



Need Help finding something?

Check out the Genesys Knowledge Network - your all-in-one access point for Genesys resources