Legacy Dev Forum Posts

 View Only

Sign Up

Access Token Expiring Early for Client Credentials Grant Type

  • 1.  Access Token Expiring Early for Client Credentials Grant Type

    Posted 06-05-2025 18:33

    Dileepkaranki | 2024-11-27 13:38:07 UTC | #1

    I am obtaining a Client Credentials access token to call the Query for Conversation Details API. I have set the token expiration to 24 hours, and the token is issued with a 24-hour expiration. However, the token occasionally expires early, sometimes after only 10 hours.

    Here is an example:

    • "expiryDate": "2024-11-27T17:30:36.9621875Z"
    • "UtilizedDate": "Wed, 27 Nov 2024 07:21:22 GMT"

    This is the error message returned...

    { "message": "Invalid login credentials.", "code": "bad.credentials", "status": 401, "contextId": "f81ce0c8-61da-4955-b808-fcc72a7207f6", "details": [], "errors": [] }


    tim.smith | 2024-11-27 15:11:47 UTC | #2

    A well-formed application must be able to handle expired tokens and should automatically get a new token when this happens. If you require an investigation for this, please open a case with Care.


    Dileepkaranki | 2024-11-27 16:21:18 UTC | #3

    Regarding this

    A well-formed application must be able to handle expired tokens and should automatically get a new token when this happens

    Are you referring to Verify user token before utilizing the token.


    tim.smith | 2024-11-27 16:28:01 UTC | #4

    No, I'm referring to this:

    Dileepkaranki, post:1, topic:30585
    This is the error message returned...

    { "message": "Invalid login credentials.", "code": "bad.credentials", "status": 401, "contextId": "f81ce0c8-61da-4955-b808-fcc72a7207f6", "details": [], "errors": [] }

    Your app should handle this 401 and get a new token at that time, then retry the request with the new token. Making an additional API request to check the status of the token is redundant and will cut your rate limit in half. You'll get the same 401 from any API endpoint whenever your token is invalid.

    It would be ok to have a timer in your app that proactively gets a new token a few minutes before the expected expiration, but otherwise doing anything proactive to validate the token isn't necessary and your app should simply be responsive to handling failure conditions.


    Dileepkaranki | 2024-11-29 15:16:16 UTC | #5

    @tim.smith @EosRios Is the issue due to HIPAA Enabled in the org https://developer.genesys.cloud/forum/t/access-token-expiring-early/22298/11?u=dileepkaranki ![Screenshot20241128003645Chrome|640x500](upload://mheOV3noCzJBCyJydHVdU0WBPo9.jpeg) https://help.mypurecloud.com/articles/hipaa-compliance/


    tim.smith | 2024-12-01 21:39:26 UTC | #6

    tim.smith, post:2, topic:30585
    If you require an investigation for this, please open a case with Care.

    @Dileepkaranki We don't have access to your org's data via the forum. Please open a case with Care for further investigation.


    Nick_Tait | 2024-12-04 02:34:07 UTC | #7

    Probably a long-shot, but have you checked what value is returned by GET /api/v2/tokens/timeout ?


    Dileepkaranki | 2024-12-04 03:27:28 UTC | #8

    FYI @tim.smith Case is raised and we understand the issue. The bottleneck is in our .net method to get token which is causing the issue. Previously it was not asynchronous and when we changed to asynchronous the issue is triggered and when the load is high on the application.


    system | 2025-01-04 03:28:27 UTC | #9

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