【发布时间】:2021-10-14 07:16:02
【问题描述】:
我正在尝试使用 Google 服务帐户从 Google Drive 下载文件。为此,我创建了一个项目,创建了一个服务帐户和密钥。 现在,当我尝试使用 google auth api 时,它返回未定义。
请在下面找到代码。
const scope = ["https://www.googleapis.com/auth/drive"];
const authService = new google.auth.GoogleAuth({
keyFile: "./service.json",
scopes: scope,
});
这会返回类似下面的内容,
GoogleAuth {
checkIsGCE: undefined,
jsonContent: null,
cachedCredential: null,
_cachedProjectId: null,
keyFilename: './service.json',
scopes: [ 'https://www.googleapis.com/auth/cloud-platform' ],
clientOptions: undefined
}
虽然 service.json 位于同一个文件夹中并从工作区本身复制了凭据。
请告诉我。谢谢
【问题讨论】:
标签: javascript node.js google-drive-api google-api-nodejs-client