我使用了以下代码段:
let {google} = require('googleapis');
let privatekey = require("./privatekey.json");
// configure a JWT auth client
let jwtClient = new google.auth.JWT(
privatekey.client_email,
null,
privatekey.private_key,
[
'https://www.googleapis.com/auth/admin.directory.user',
'https://www.googleapis.com/auth/admin.directory.user.readonly',
'https://www.googleapis.com/auth/admin.directory.group',
//'https://www.googleapis.com/auth/plus.business.manage'
],
'mybusinessacc.com'
);
//authenticate request
jwtClient.authorize(function (err, tokens) {
if (err) {
console.log(err);
return;
} else {
console.log("Successfully connected!");
}
});
哪个连接成功,但是当我按此说明访问任何目录API时http://googleapis.github.io/google-api-nodejs-client/modules/_apis_admin_directory_v1_.html 我收到此错误:API返回错误:需要登录