Skip to main content
Question

Can get AccessToken but refresh Token is coming null

  • May 23, 2025
  • 1 reply
  • 1 view

Forum|alt.badge.img

Hi

We have set up ServerAuthClientCredGrant

 

I have this code

 

        BoxCCGAPIConnection api = BoxCCGAPIConnection.userConnection(clientId, clientSecret, userId);
        System.out.println("-New AccessToken-" + api.getAccessToken());
        System.out.println("-New RefreshToken-" + api.getRefreshToken());

 

The accessToekn has a value but Refresh Token is always null

1 reply

Forum|alt.badge.img

Hi

The server auth methods (CCG and JWT) do not return a refresh token. The getAccessToken() method has refresh logic built in and will refresh the token when required. See http://opensource.box.com/box-java-sdk/javadoc/com/box/sdk/BoxAPIConnection.html#getAccessToken--

A refresh token is only returned when you exchange an OAuth authorization code for a token/refresh token pair

Best regards

Peter Christensen, Platform Solutions Engineer, Box