21
votes

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.

8
The request requires your Google Account number, otherwise, the connection will fail.jdweng
I ran your id with code form following and it say key invalid : stackoverflow.com/questions/34597229/…jdweng
why ? but Client ID is trueÖmer ARGIN
I have exactly the same error, it started from last week. Have you found a way to fixed that? I feel that something went wrong on Google's side with my ClientId record... Maybe they were working on something and we got the "side-effect"?Axel186
Did anyone manage to find a solution to this error? I'm just trying to implement Google Sign-in and the error still occurs Jan 2020. Anyone?regan

8 Answers

21
votes

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

2
votes

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
votes

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?

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.

0
votes

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

0
votes

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.

0
votes

This issue can be fixed using the 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);
    }
}));
0
votes

I was also having the same issue but with my Rails app. So I resolved it by upgrading the omniauth gems by running bundle update devise omniauth omniauth-google-oauth2 in terminal.

0
votes

I also faced the same issue. This issue may occur for using the old library, enable the google people Api for your project, and download the library as per your php version from this link and integrate it.