Legacy Dev Forum Posts

 View Only

Sign Up

KeyError when using get_code_authorization_token

  • 1.  KeyError when using get_code_authorization_token

    Posted 06-05-2025 18:08

    eparis | 2022-09-28 16:47:14 UTC | #1

    Hello.

    When using code authorization grant authentication with the Python SDK, I get a KeyError about the method being unable to get the refresh token.

    Line in code that generates the error is the following: " apiclient, authtokeninfo = PureCloudPlatformClientV2.apiclient.ApiClient().getcodeauthorizationtoken(....) "

    Throws the following error, with: ERROR: /usr/local/lib/python3.10/site-packages/PureCloudPlatformClientV2/apiclient.py, line 206, in getcodeauthorizationtoken: self.refreshtoken = data[0]["refreshtoken"]

    Value of "data" in runtime was: [{'accesstoken': '...................', 'expiresin': 86398, 'token_type': 'bearer'}]

    So from what I can deduce, "data" is returning the expected values of accesstoken, expiresin, and tokentype; but not "refreshtoken". Why is this happening? How can I fix this?

    I have used this python authentication method before and it worked fine. I even want back and logged the values of "data" in those authentications, and I could see it WAS returning "refresh_token".

    Thanks for any help you can give.


    anon14299330 | 2022-10-07 14:06:50 UTC | #2

    Hi,

    Currently investigating and will update soon.

    Thanks,

    Mike


    system | 2022-11-07 14:07:45 UTC | #3

    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: 16493