Saving Google Access Token to a Variable

Hi, am trying to save a users access token to a variable so it can be used in a http.get call to the YouTube API.

My code to get the Access token looks like so:

//SERVER SIDE

Meteor.methods({
getAccessToken : function() {
try {
return Meteor.user().services.google.accessToken;
} catch(e) {
return null;
}
}
});

//CLIENT SIDE

indent preformatted text by 4 spaces
if (error){
console(error);
}
else{
console.log(accessToken);
}
});

The console.log print out the correct Access token but I need it to be saved to a variable so it can be used dynamicaly

1 Like