Search code examples
box-api

Error when using box-java-sdk


I have tried to create App user with box-java-sdk example in that link https://github.com/box/box-java-sdk

And here is the code parameters :

private static final String CLIENT_ID = "qve5jn#############yz6azyh7tabfs";
private static final String CLIENT_SECRET = "kELXWLp8e#############KjKOayc";
private static final String ENTERPRISE_ID = "946313";
private static final String PUBLIC_KEY_ID = "l925y3o8";
private static final String PRIVATE_KEY_FILE = "/home/baddar/.ssh/private_key.pem";
private static final String PRIVATE_KEY_PASSWORD = "hello";
private static final String APP_USER_NAME = "mbaddar1";
private static final int MAX_CACHE_ENTRIES = 100;

However , I always have the error

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

Any ideas ?


Solution

  • I'll explain why you are seeing this error, and then how to fix it.

    When the Box Java SDK generates a request for the App User access token, it uses the current UTC time as part of this request. If the Unix time on your local machine and the Box server are out of sync, you will see the exp claim error.

    To fix this error, update the Unix time on your machine to match the Unix time from this site. Then retry your request to generate the App User access token.