Genesys Cloud - Main

 View Only


Discussion Thread View
  • 1.  API to get Access Token for Client Credentials Grant Type

    Posted 06-04-2024 10:05

    Hi Guys,

    I am trying to use the following API

    POST https://login.usw2.pure.cloud/oauth/token

    with Header

    Content-Type: application/x-www-form-urlencoded

     Authorization: Basic BASE64(<client_id>:<client_secret>) 

    Body,

    grant_type=client_credentials

    I replaced the client ID and Secret with required Oauth Integration, but it seems to give me 400 error 

    {"error":"invalid_client","description":"no client id provided","error_description":"no client id provided"}
    I need your eye to check to see if I am doing anything wrong or need to cater for anything else apart from what is posted above.
    Would appreciate your assistance.

    #Integrations

    ------------------------------
    Sagar Tawde
    MetLife Services and Solutions, LLC
    ------------------------------


  • 2.  RE: API to get Access Token for Client Credentials Grant Type
    Best Answer

    GENESYS
    Posted 06-05-2024 09:55

    Hi Sagar,

    In the "Authorization" header are you actually base64 endcoding the client id and secret and sending the encoded string?

    For instance if I have the following client id = "Jim" and secret = "Crespino".  If I base64 encode "Jim:Crespino", then I get the string "SmltOkNyZXNwaW5v".  Then my Authorization header value should be "Basic SmltOkNyZXNwaW5v".

    Most programming languages have libraries that will perform a base64 encode routine.  If you need to do it manually then there are many online tools, such as this one: https://www.base64encode.org/

    Note, base64 encoding is not encrypting.  You can easily decode any encoded string, so please continue to protect the client id and secret, as they are essentially a username and password to your org with authorization to perform any API request granted by the permissions of the role assigned to that OAuth client.

    By the way, you might consider posting development related questions into the Genesys Cloud Developer Forum at https://developer.genesys.cloud/forum.

    Cheers,



    ------------------------------
    Jim Crespino
    Senior Director, Developer Evangelism
    Genesys
    https://developer.genesys.com
    ------------------------------



  • 3.  RE: API to get Access Token for Client Credentials Grant Type

    Posted 06-05-2024 13:50

    Thank You Jim. encoding to base64 worked. Appreciate your help!



    ------------------------------
    Sagar Tawde
    MetLife Services and Solutions, LLC
    ------------------------------



Need Help finding something?

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