I'm building a gmail app in Node for personal use/learning and have gotten fairly far, but now I'm stuck at something that is probably pretty noobish.
In the app, I have the authorization function (taken from Google's quickstart.js tutorial), and then I run a function that grabs the latest 10 emails and their header data and prints them into a list. This list contains a data attribute with that emails unique ID.
I figured it would be fairly simple to do an on click event that now passes the clicked email's ID to a function to retrieve the full email. The problem is that in order to retrieve the data, I need to pass the auth
to the function.
`// get the message from the message ID
function getFullMessage(auth,id) {
var gmail = google.gmail('v1');
messageId = id;
var request = gmail.users.messages.get({
'auth': auth,
'userId': 'me',
'id': messageId
}, function(err, response) {
if (err) {
alert('The API returned an error: ' + err);
return;
}
else {
setFullMessagePanel(response.payload.body)
}})
}`
So my question is, how do I get that function to authenticate when I cannot pass the auth attribute to it? Is there a way to set a global auth
variable or something?
via Harmonic
No comments:
Post a Comment