Im trying to construct an OAuth2 request to the Box API. The example POST request they give as a guideline is a bit ambiguous to me as I am recently learning backend development. The example is as follows:
POST /tokenContent-Type: application/x-www-form-urlencoded grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer& assertion=<JWT>& client_id=<client_id>& client_secret=<client_secret> Official Docs: https://box-content.readme.io/docs/app-auth The way I attempted to do this is as follows: var boxHeaders = { 'Content-Type': 'application/x-www-form-urlencoded'}; var boxOptions = { url: 'https://api.box.com/oauth2/token', method: 'POST', headers: boxHeaders, form: { 'grant_type': 'urn:ietf:params:oauth:grant-type:jwt-bearer', 'assertion': boxtoken, 'client_id': 'myclientid', 'client_secret': 'myclientsecret' }}; request.post(boxOptions, function(err, response, body) { console.log(body);}); I get the following error: { "error":"invalid_request", "error_description":"Invalid grant_type parameter or parameter missing" } Obviously the grant type is incorrect but I have no idea how to go about constructing the string based on the Box API example. If anyone can help and even expose me to some good articles or tutorials on how to do this, that would be great! Thank you. -- Job board: http://jobs.nodejs.org/ New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. To post to this group, send email to nodejs@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/a44061da-5338-4233-b94e-a4e31a86dbd0%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.