Legacy Dev Forum Posts

 View Only

Sign Up

About the 'auth_code' Argument in the apiclient.get_code_authorization_token Function

  • 1.  About the 'auth_code' Argument in the apiclient.get_code_authorization_token Function

    Posted 06-05-2025 18:09

    lxlhrbr | 2023-11-09 07:58:52 UTC | #1

    Hello,

    https://developer.genesys.cloud/devapps/sdk/python I have a question about the sample code for Authorization Code Grant on this page. Where should I obtain the data to be input as the 'authcode' argument for the apiclient.getcodeauthorizationtoken function? My goal is to obtain a new access token using a refresh token.


    tim.smith | 2023-11-09 14:24:16 UTC | #2

    If you follow your link above and click on the Authorization Code Grant doc link, that page documents how to use the auth code grant. In the Get the OAuth Client Information section, it describes how to create and obtain the oauth client information.


    ObsTech | 2023-11-13 20:03:06 UTC | #3

    lxlhrbr,

    I ran into this confusion as well when I first started using the auth code grand with the SDK. In the document Tim mentioned it shows that you need to first send your user to the following address

    Https://login.(host URL)/oauth/authorize

    The host URL will depend on where your org is located. All of the info in the documentation is "mypurecloud.com" which is us-east-1. You will need to change that part to your region if you are not in us-east-1. There is a listing on this page under the "Core Regions" tab https://help.mypurecloud.com/articles/aws-regions-for-genesys-cloud-deployment/

    Next, you will need to add the following parameters to the URL clientid, responsetype, and redirect_uri.

    The client ID will be your OAuth's ID, the responsetype will be "code", and the redirecturi will be the address you want the response to this call to be directed to. It should look something like this:

    Https://login.mypurecloud.com/oauth/authorize?client_id=yourClientId&response_type=code&redirect_uri=yourRedirectUri

    Once you direct the user to this URL they will be prompted for a Genesys login unless they are already logged in. You can force a login by adding &prompt=login to the end of the example URL.

    Once they successfully log in Genesys will send them back to the URL you provided in the redirect URI with a code parameter attached to the end of the URL

    example - https://yourUrl.com?code=generatedCode

    This will be the auth code that you are passing to the SDK.

    Hopefully that makes sense, and I believe it is all in the documentation. But I do recall struggling with it myself when I first tried to set it up.


    system | 2023-12-14 20:03:10 UTC | #4

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


    This post was migrated from the old Developer Forum.

    ref: 23016