I am building an application in SailsJS (v0.11) and Angular (v1.4.4) based on the Google API.
I use the Google Drive NodeJS library to get the user permission ID . Unfortunately this will not work. I use the following code to get the permission id.
sails.googleDrive.permissions.getIdForEmail({
email: user.email
}, function(error, permissions) {
console.log(error);
});
The code gives me the following output.
{
[
Error: LoginRequired
]
code: 401,
errors: [
{
domain: 'global',
reason: 'required',
message: 'Login Required',
locationType: 'header',
location: 'Authorization'
}
]
}
All other things in my application, such as uploading files and pasting permissions on files and folders, work as expected. getIdForEmail
is the only call that gives this error.
I am initializing the Google API as shown below.
var clientId = 'XXXXXXXXXXXXXXXXXXXX.apps.googleusercontent.com';
var clientSecret = 'XXXXXXXXXXXXXXXXXXXX';
var redirectUrl = 'http://XXXXXXXXXXXXXXXXXXXX/user/login/oauth2callback';
sails.google = require('googleapis');
sails.googleAuth = new sails.google.auth.OAuth2(clientId, clientSecret, redirectUrl);
sails.googlePlus = sails.google.plus('v1');
sails.googleCalendar = sails.google.calendar('v3');
sails.googleDrive = sails.google.drive('v2');
I hope someone can help me here :)