0

I am trying to use Box API for android sdk v2. I am able to successfully access the files after doing the first time authentication. I am able to do that using that same Access Token but after an hour it gets timedout. I dont know how to use that refresh token and get a new token from box api. Following is the Map which i use to create a BoxAndroidOAuthData object.

     Map<String, Object> authMap = new HashMap<String, Object>();
        authMap.put("access_token", sp.getString(ACCESSTOKEN, null));
        authMap.put("expires_in", 3600);
        authMap.put("restricted_to", "[]");
        authMap.put("token_type", "bearer");
        authMap.put("refresh_token", sp.getString(REFRESHTOKEN, null));

Here is the building of BoxAndroidOAuthData object.

    BoxAndroidOAuthData oauth = new BoxAndroidOAuthData(getOAuthData());
       BoxAndroidClient client = new BoxAndroidClient(
       TestBoxnetApplication.CLIENT_ID,TestBoxnetApplication.CLIENT_SECRET, null, null);
       client.authenticate(oauth);

I have even kept oAuthRefreshListener but i never get anything logged in there.

   client.addOAuthRefreshListener(new OAuthRefreshListener() {
       @Override
       public void onRefresh(IAuthData newAuthData) {
           System.out.println("new authentication token:"+ newAuthData.getAccessToken());
           saveOAuthData(newAuthData.getAccessToken(),newAuthData.getRefreshToken());
       }
   });

I don't have any idea how to use RefreshToken and get a new accesstoken and save it to use it further. Please help.

Thanks

Udit Shah
  • 241
  • 2
  • 14

0 Answers0