403 Message: Legacy People API has not been used in project

余生长醉 提交于 2020-03-21 11:14:33

问题


Google API is active but give error ; Legacy People API has not been used in project before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/legacypeople.googleapis.com/overview?project= then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.


回答1:


Before the Google+ API Shutdown on March 7, 2019, the people.get and people.getOpenIdConnect methods were available for requesting a person’s profile.

To avoid breaking existing integrations with these methods supporting sign-in, a new minimal implementation only returns basic fields necessary for that functionality, such as name and email address, if authorized by the user. The Legacy People API is where these methods will remain available for existing callers at the existing HTTP endpoints.

The Legacy People API serves a limited new implementation of the legacy Google+ API people.get and people.getOpenIdConnect methods necessary for maintaining sign-in functionality. It is available to existing callers of the original methods that haven't migrated to recommended replacements such as Google Sign-in or Google People API at the time of the Google+ API shutdown.

enter link description here

Thanks




回答2:


You don't need to install any other APIs like Google Drive API, Google Sheets API or other except Google+ API,

The error is coming because of "passport-google-oauth": "^1.0.0"

Just change the version "passport-google-oauth": "^1.0.0" to "passport-google-oauth": "^2.0.0" and remove node_modules and package.lock.json file and run "npm i"

That's it




回答3:


In this case, I'm facing the same issue. This is what I've done to fix it.

Situation:

  • NodeJS ver 8
  • "passport-google-oauth": "^1.0.0"
  • Using Google+ API as Google Sign-in

When I run the apps and click Sign in with Google, what happened then?

  • Server error
  • Error log: Legacy People API has not been used in project "xxxx" before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/legacypeople.googleapis.com/overview?project=xxxx then retry.

How I solve it?

  • Go to Google Console
  • Click on Google+ API under Social APIs, then click Enable API
  • Click on Google Drive API under G Suite, then click Enable API
  • Click on Google Sheets API under G Suite, then click Enable API
  • Update "passport-google-oauth": "^1.0.0" to "passport-google-oauth": "^2.0.0" in package.json
  • remove package-lock.json and node_modules folder (to ensure everything is clear)
  • run this command : npm install
  • It works now!

Note: my previous code still using profile._json.image.url to get profile image. Actually, this response was not there anymore. So I delete this code. Goodbye Google+ Thank you Google People API.




回答4:


Enabling the Google Contacts API and the Google+ API fixed this issue for me.




回答5:


Hi I recently stumbeled on the same issue. As explained by Ilan Laloum, Google+ API as been decommissionned completely for new projects.

I found that Google People API works in a similar way. The following example is based on the Bookshelf tutorial in GCP. Source code can be seen here: https://github.com/GoogleCloudPlatform/golang-samples/tree/appengine/go111/cloudsql/getting-started/bookshelf (branch 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()
}

This method needs a context and a OAuth token, just like Google+ API used to. The peopleService is initialized in a similar fashion.

The peopleService.People.Get("people/me") prepares a query that fetches the profile of the connected user. Then PersonFields("names,coverPhotos,emailAddresses") is a filter on profile fields. This part of the request is mandatory. Eventually Do() will execute the request.



来源:https://stackoverflow.com/questions/58645078/403-message-legacy-people-api-has-not-been-used-in-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!