Legacy Dev Forum Posts

 View Only

Sign Up

401 with loginClientCredentialsGrant

  • 1.  401 with loginClientCredentialsGrant

    Posted 06-05-2025 18:27

    James_Tarling | 2023-07-19 07:39:00 UTC | #1

    Hi,

    We're using the platform SDK on a node app - we're using loginClientCredentialsGrant

    After successfully making some requests, some time later we begin to see 401 errors.

    Should we be looking for expired tokens and refreshing them or is this refresh mechanism built into the client?

    Thanks


    Hemanth | 2023-07-19 10:16:05 UTC | #2

    Hi

    You are using loginClientCredentialsGrant and we have refresh token mechanism built in the client SDK . So whenever you have 401 it will look out for the expired tokens and try to refresh them. But you need to set the this.refreshaccesstoken = true; for your 'Configuration' instance. Hope this helps.


    Lucas1 | 2023-07-19 11:16:58 UTC | #3

    Hi Hemanth,

    Thanks for the response, I'm Jame's colleague.

    Debugging the code for purecloud-platform-client-v2 the auth request made by loginClientCredentialsGrant does not receive a refresh token in the response (see screenshot), so the subsequent code that tries to refresh the token fails.


    Hemanth | 2023-07-19 14:05:07 UTC | #5

    Hi Lucas and James.

    you are right. As the snaspshot shot shows the refreshtoken will not be set for loginClientCredentialsGrant. It is available for auth grants. loginCodeAuthorizationGrant.

    For loginClientCredentialsGrant if your token is expired , you need to rerun the login function to get a new token exactly like how you got it the first time

    BR Hemanth


    system | 2023-08-19 14:05:56 UTC | #6

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