Refresh Tokens is NULL on 114.0.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(CLIENT_ID,CLIENT_SECRET, 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

Hi Jaime,

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

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

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());

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