Java SDK JWT authentication

新規投稿

コメント

3件のコメント

  • kendomen

    If you get your managed user like this:

     

    BoxDeveloperEditionAPIConnection userApi = BoxDeveloperEditionAPIConnection.getAppUserConnection("userid", CLIENT_ID, CLIENT_SECRET, encryptionPref, accessTokenCache);
    
    

    that should work.

     

    Here's the entire example:

    https://github.com/kendomen/BoxJavaJWTExamples/blob/master/src/com/nike/box/UploadFileAsEnterpriseAdmin.java

    0
    コメントアクション パーマリンク
  • narendraN

    Thank you for your reply ...

     

    I replaced Enterprise id with userID  got below exception

     

    BoxDeveloperEditionAPIConnection userApi = BoxDeveloperEditionAPIConnection.getAppUserConnection("userid","fthdms9f0s89nwfvsl4uamikeu7txh20", "3wUzMT7cjWktvEmlcddzSSLpUFmcteWl", encryption, accessTokenCache);

     

    {invalid_grant","error_description":"Please check the 'exp' claim."} , i found solution  to

    update the Unix time on your machine to match the Unix time  ,

    but i am using windows machine. how can i set this unix time or set 'exp' claim programatically  ?

     

    Any help is greatly appreciated..

     

    0
    コメントアクション パーマリンク
  • kendomen

    That's in box-java-sdk in class BoxDeveloperEditionApiConnection

     

    private String constructJWTAssertion() {
            JwtClaims claims = new JwtClaims();
            claims.setIssuer(this.getClientID());
            claims.setAudience(JWT_AUDIENCE);
            claims.setExpirationTimeMinutesInTheFuture(1.0f);
            claims.setSubject(this.entityID);
            claims.setClaim("box_sub_type", this.entityType.toString());
            claims.setGeneratedJwtId(64);
    
            JsonWebSignature jws = new JsonWebSignature();
            jws.setPayload(claims.toJson());
            jws.setKey(this.decryptPrivateKey());
            jws.setAlgorithmHeaderValue(this.getAlgorithmIdentifier());
            jws.setHeader("typ", "JWT");

     

    0
    コメントアクション パーマリンク

サインインしてコメントを残してください。