Using JSON Web Token (JWT) to Obtain Authorization Token for server-side application to send email using Google API

40 views
Skip to first unread message

Raymond Rugemalira

unread,
Dec 29, 2015, 9:59:55 PM12/29/15
to nodejs
I'd like to use a JSON Web Token (JWT) to obtain for my server-based application an authorization token to send email.

In forming the jwtClaimSet I need to include: "iss", "scope", "aud", "exp" and "iat"

I have a question regarding "scope".

Out of these two, what should it be for sending email?

I'd like to use:
var request = require('/usr/local/lib/node_modules/request');
request(options, function (error, response, body) { ... }

var options = { ...};
contains:

method: "POST",
headers: "Content-Type": "application/x-www-form-urlencoded",
body: "encodedData", // Is this correct? What should it be?
//uri: "https://accounts.google.com/o/oauth2/token", // Which one out of the above choices?
grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer", // This one causes an error! How should I specify grant_type?
assertion: fullJWT // Where  var fullJWT = encodedJwtHeader + "." + encodedClaim + "." + signature;

I get the error:
'{\n   var fullJWT = encodedJwtHeader + "." + encodedClaim + "." + signature;\n}' 

This message is very criptic and I need help. Will appreciate your responses as I've been debugging for the last three days!!






Reply all
Reply to author
Forward
0 new messages