Often signing your first JWT on the Box Platform, you might run into a few problems. Here is one of those errors you might run into when trying to get an access token:
{"error":"invalid_grant","error_description":"Current date\/time MUST be before the expiration date\/time listed in the 'exp' claim"}
If you find yourself experiencing this error, I would remove the timestamp from the JWT. Here is what that might look like when using a node jwt library.
var jwt = require('jsonwebtoken');
var signed_token = jwt.sign({
iss: API_token,
sub: ent_id,
box_sub_type: "enterprise",
aud: "https://api.box.com/oauth2/token",
jti: sessionToken,
exp: expiringTime
}, { key: privateKey, passphrase: jwt_secret }, { algorithm: 'RS256', noTimestamp: true });
The removal of the timestamp will make sure the JWT is properly signed and will most likely remove your error assuming that your expiringTime was created right.
I would recommend checkout my little command line tool. It can be found on GitHub.
