gpt4 book ai didi

google-chrome-extension - 为 "googleapis.com/auth/userinfo"启用 Google API

转载 作者:行者123 更新时间:2023-12-01 22:09:57 32 4
gpt4 key购买 nike

我正在开发 Google Chrome 扩展程序。我希望能够使用来自这些端点的数据访问用户个人资料信息:

https://www.googleapis.com/auth/userinfo

https://www.googleapis.com/oauth2/v1/userinfo

我似乎无法访问这些资源。从我的网络搜索来看,我可能需要在 Google Developers Console 中启用一个库 API。但我在那里看了看,找不到合适的 API 来启用。有谁知道我应该启用哪个 API?

最佳答案

您至少需要按照上述添加范围 https://www.googleapis.com/auth/userinfo.profile

然后您可以像使用sheetscalendar 等一样使用oauth2 api。

在 nodejs 中,它会是这样的:

    const { google } = require('googleapis')
const auth = new google.auth.OAuth2(
keys.web.client_id,
keys.web.client_secret,
keys.web.redirect_uris[0]
)
// get the tokens from google
auth.credentials = tokens
const oauth2 = google.oauth2({ version: 'v2', auth })
const userinfo = await oauth2.userinfo.get()
console.log(userinfo)

API 记录在此处:https://googleapis.dev/nodejs/googleapis/latest/oauth2/interfaces/Schema$Userinfo.html#info .那里的源代码中也有一些示例。

关于google-chrome-extension - 为 "googleapis.com/auth/userinfo"启用 Google API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48632883/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com