Pages

Thursday, November 17, 2016

"{"error":"invalid_grant","error_description":"Please check the 'exp' claim."}"

Hi,

I am getting the following error while sending the JWT Token request to https://api.box.com/oauth2/token

Error:


"{"error":"invalid_grant","error_description":"Please check the 'exp' claim."}"


Solution:

long DEVIDE=1000L;
long currentTime=System.currentTimeMillis();
long seconds=(currentTime/DEVIDE);
seconds=seconds+60L;


Map<String, Object> claims= new HashMap<String,Object>();
claims.put("iss", CLIENT_ID);
claims.put("sub", SUBJECT_ID);
claims.put("box_sub_type", "user");
claims.put("aud", "https://api.box.com/oauth2/token");
claims.put("jti", UUID.randomUUID());
long currentTime=System.currentTimeMillis();
long seconds=(currentTime/DEVIDE);
seconds=seconds+60l;
claims.put("exp",seconds);

After modifying the code issue will be resolved.

1 comment: