Legacy Dev Forum Posts

 View Only

Sign Up

Refresh Tokens is NULL on 114.0.1

  • 1.  Refresh Tokens is NULL on 114.0.1

    Posted 06-05-2025 18:18

    Jaime_Martinez | 2021-01-24 16:45:11 UTC | #1

    Hi, I'm trying to add refresh tokens capability on my application and the refresh token is always 'null' with option of withShouldRefreshAccessToken either false or true on ApiClient.Builder. Below is always my print line: Authentication successful. Access token expires in 86399 seconds Authentication successful. Access refresh token null

    That is, it gives out NPE at cron job every time I invoked below: this.apiClient.refreshCodeAuthorization(CLIENTID,CLIENTSECRET, this.refreshToken)

    Would it be possible to help me on this one? Or do I need to lower the version of the sdk?

    Cheers, Jaime Martinez


    anon11147534 | 2021-01-25 08:55:53 UTC | #2

    Hi Jaime,

    Are you using Code Authorization as your grant method? Refresh tokens only work with Code Authorization.


    Jaime_Martinez | 2021-01-25 11:55:33 UTC | #3

    Hi Ronan, Yes I am using code authorization. For now, instead of using refreshing it. I delete the token and create new one on cron job.

    Thanks


    anon11147534 | 2021-01-25 14:31:00 UTC | #4

    Hi Jaime,

    I'm unsure why that's not working for you. This is my code that works perfectly:

    String clientId = System.getenv("CLIENT_ID");
    String clientSecret = System.getenv("CLIENT_SECRET");
    String redirectURI = "http://myredirecturi.com/";
    String authCode = "my_auth_code";
    
    //Set Region
    PureCloudRegionHosts region = PureCloudRegionHosts.us_east_1;
    
    ApiClient apiClient = ApiClient.Builder.standard()
            .withBasePath(region)
            .build();
    ApiResponse<AuthResponse> authResponse = apiClient.authorizeCodeAuthorization(clientId, clientSecret, authCode, redirectURI);
    
    System.out.println("refresh token " + authResponse.getBody().getRefresh_token());

    system | 2021-02-25 14:31:02 UTC | #5

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