I am trying to download attachment using Gmail API and below is the code for the that
var Data = req.body;
var parts = Data.payload.parts;
for (var i = 0; i < parts.length; i++) {
var part = parts[i];
if (part.filename && part.filename.length > 0) {
var attachId = part.body.attachmentId;
var request = gapi.client.gmail.users.messages.attachments.get({
'id': attachId,
'messageId': message.id,
'userId': userId
});
request.execute(function(attachment) {
callback(part.filename, part.mimeType, attachment);
});
}
}
I have used the link Gmail API to get the Attachment and since it require autorization as mention so who to pass the refershToken,clientSecret,clientId,accessToken etc..or whether this is required first place.
Currently i am getting Gmail is not defined, i have installed gapi and included it as
var cs = require("coffee-script/register");
var gapi = require('gapi');`