这个流程让我有点困惑,我非常感谢任何能帮助我更好地理解这一点的帮助/图表/流程图:
举个例子,我想访问Google的API。问题是,我想要访问的是企业帐户,甚至要使用任何Google Suite应用程序,我必须登录到我的工作帐户(SSO)。最重要的是,所有这些都需要通过VPN来完成。
我在Node.js中使用过Puppeteer,虽然它可以在我的机器上工作,但如果我尝试将它托管到其他地方,它就会停止工作,因为(我假设)是由于VPN问题。这是笨拙和纯粹的黑客,因为我只是自动化我通常在浏览器上做的事情。
能够使用Google的API的最佳实践是什么?这个算法是什么样子的?
发布于 2019-08-27 02:55:28
你可以在npm https://www.npmjs.com/package/googleapis上使用'googleapis‘包
这里有一个例子..。
const {google} = require('googleapis');
const bigquery = google.bigquery('v2');
async function main() {
// This method looks for the GCLOUD_PROJECT and GOOGLE_APPLICATION_CREDENTIALS
// environment variables.
const auth = new google.auth.GoogleAuth({
scopes: ['https://www.googleapis.com/auth/cloud-platform']
});
const authClient = await auth.getClient();
const projectId = await auth.getProjectId();
const request = {
projectId,
datasetId: '<YOUR_DATASET_ID>',
// This is a "request-level" option
auth: authClient
};
const res = await bigquery.datasets.delete(request);
console.log(res.data);
}
main().catch(console.error);您可以通过设置process.env.http或process.env.https环境变量来使用代理来解决您的vpn问题
https://stackoverflow.com/questions/57662804
复制相似问题