403消息:Legacy People API未在项目中使用


14

Google API已启用,但给出了错误;旧版People API之前尚未在项目中使用过,或者已被禁用。通过访问https://console.developers.google.com/apis/api/legacypeople.googleapis.com/overview?project=启用它,然后重试。如果您最近启用了此API,请等待几分钟,以便该操作传播到我们的系统并重试。


该请求需要您的Google帐号,否则连接将失败。
jdweng

我使用以下代码形式运行了您的ID,并说密钥无效:stackoverflow.com/questions/34597229/…–
jdweng

为什么呢?但客户端ID是真实的
奥马尔ARGIN

2
我有完全一样的错误,它是从上周开始的。您是否找到解决该问题的方法?我觉得我的ClientId记录在Google方面出了问题...也许他们在做某些事情,而我们却获得了“副作用”?
Axel186 '19

2
有人设法找到解决此错误的方法吗?我只是尝试实施Google登录,并且该错误仍然在2020年1月发生。有人吗?
里根

Answers:


6

您不需要安装其他任何API,例如Google Drive API,Google Sheets API或Google+ API以外的其他API,

由于“ passport-google-oauth”而出现错误:“ ^ 1.0.0”

只需将版本“ passport-google-oauth”:“ ^ 1.0.0”更改为“ passport-google-oauth”:“ ^ 2.0.0”,然后删除node_modules和package.lock.json文件并运行“ npm i”

而已


你摇滚!谢谢!我实际上是在使用passport-google-oauth20@1.0.0,因此2.0在阅读您的答案后便将其删除并安装了该版本,并且可以正常工作。
丹尼尔

谢谢,它的工作原理,你是冠军
Bhagvat Lande

2

在2019年3月7日Google+ API关闭之前,people.get和people.getOpenIdConnect方法可用于请求人员的个人资料。

为了避免使用支持登录的这些方法破坏现有的集成,如果用户授权,新的最小实现仅返回该功能所需的基本字段,例如名称和电子邮件地址。Legacy People API是这些方法将在现有HTTP端点上的现有调用方仍然可用的地方。

旧版People API为旧版Google+ API的有限新实现提供了服务,这是维护登录功能所必需的people.get和people.getOpenIdConnect方法。Google+ API关闭时,尚未迁移到建议的替代方法(例如Google Sign-inGoogle People API)的现有调用方可以使用它。

在此处输入链接说明

谢谢


1

在这种情况下,我面临着同样的问题。这是我为修复此问题所做的工作。

情况:

  • NodeJS版本8
  • “ passport-google-oauth”:“ ^ 1.0.0”
  • 使用Google+ API作为Google登录

当我运行应用程序并单击“使用Google登录”时,发生了什么?

我该如何解决?

  • 转到Google控制台
  • 点击社交API下的Google+ API,然后点击启用API
  • 点击G Suite下的Google Drive API,然后点击Enable API
  • 点击G Suite下的Google Sheets API,然后点击Enable API
  • 将package.json中的“ passport-google-oauth”:“ ^ 1.0.0”更新为“ passport-google-oauth”:“ ^ 2.0.0”
  • 删除package-lock.json和node_modules文件夹(以确保所有内容都清晰可见)
  • 运行以下命令:npm install
  • 现在可以使用!

注意:我之前的代码仍然使用profile._json.image.url来获取配置文件图像。实际上,此响应不再存在。所以我删除了这段代码。再见Google+,谢谢Google People API。


这给了我一个错误:There was an error while loading /apis/api/legacypeople.googleapis.com/overview?project=xxxx. Please try again.
Jim.B

您是否遵循了这些步骤?
鲍比

0

启用Google Contacts API和Google+ API可以解决此问题。


嗨,此操作在您执行此操作之前必须已经有效。截至目前(2020年),新项目的Google+ API已完全停用。
avi.elkharrat

0

嗨,我最近对同一个问题之以鼻。如Ilan Laloum所述,Google + API已完全停用新项目。

我发现Google People API的工作方式与此类似。以下示例基于GCP中的书架教程。可以在此处查看源代码:https : //github.com/GoogleCloudPlatform/golang-samples/tree/appengine/go111/cloudsql/getting-started/bookshelf(分支appengine/go111/cloudsql

import people "google.golang.org/api/people/v1"

...

// retrieves the profile of the user associated with the provided OAuth token
func fetchProfile(ctx context.Context, tok *oauth2.Token) (*people.Person, error) {
peopleService, err := people.NewService(ctx, option.WithTokenSource(bookshelf.OAuthConfig.TokenSource(ctx, tok)))
if err != nil {
    return nil, err
}

return peopleService.People.Get("people/me").
    PersonFields("names,coverPhotos,emailAddresses").
    Do()
}

此方法需要上下文和OAuth令牌,就像以前的Google+ API一样。在peopleService以类似的方式进行初始化。

peopleService.People.Get("people/me")准备,其获取连接的用户的个人资料的查询。然后PersonFields("names,coverPhotos,emailAddresses")是配置文件字段上的过滤器。请求的这一部分是强制性的。最终Do()将执行请求。


0

可以使用 passport-google-token

npm install passport-google-token

const GoogleStrategy = require('passport-google-token').Strategy;

// Google OAuth Strategy
passport.use('googleToken', new GoogleStrategy({
    clientID: CLIENT_ID,
    clientSecret: CLIENT_SECRET
}, async (accessToken, refreshToken, profile, done) => {
    try {
        console.log('creating a new user')
        const newUser = new User({
            google: {
                id: profile.id,
                email: profile.emails[0].value
            }
        });

        await newUser.save();
        done(null, newUser);
    } catch (error) {
        done(error, false, error.message);
    }
}));
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.