Join BoxWorks in San Francisco Nov 12-13! Keynotes, product demos, and Box Master Classes. Reserve your spot!

RSA-SHA256 JWT Box Integration

New post

Comments

2 comments

  • Murtza

     I am not sure if this will help, but here is how our Noke SDK generates a token using JWT authentication.

    0
    Comment actions Permalink
  • vinodtiwari10
    Thanks for sharing document but that is not working at our end for RSA-SHA256, 
    and I need 1 source code of any either JavaScript or NodeJS because
    my system is not accepting any reference call like: Module, require is not defined:


    var
    jwt = require('jsonwebtoken'); var fs = require('fs'); var base64url = require("base64url"); var request = require('request'); var client_id = 123 var client_secret = 123 var key = fs.readFileSync('23er444'); var passphrase = 3444 var exp = Math.round((Date.now()/1000))+60; var header = { "alg": "RS256", "typ": "JWT", "kid": keyID }; var claims = { "iss": client_id, "sub": "sss", "box_sub_type": "user", "aud": "https://api.box.com/oauth2/token", "jti": "ddsss", "exp": exp }; var encodedHeader = base64url(new Buffer(JSON.stringify(header))); var payload = base64url(new Buffer(JSON.stringify(claims))); var signature = jwt.sign(encodedHeader + '.' + payload, {key: key, passphrase: passphrase}, {algorithm: 'RS256'}); var encodedsignature = base64url(new Buffer(JSON.stringify(signature))); var jwt = encodedHeader + "." + payload + "." + encodedsignature; return jwt; var options = { uri: 'https://api.box.com/oauth2/token',method: 'POST',json: true,headers: {'content-type': 'application/x-www-form-urlencoded'},body: 'grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer&client_id=' + client_id + '&client_secret=' + client_secret + '&assertion=' + jwt };

        

    0
    Comment actions Permalink

Please sign in to leave a comment.