2

After I init the google people api gapi.client like so:

gapi.client.init with object containing the scope, api key, and client id:

  init_people_api = async () => {
    await gapi.client.init({
      apiKey: API_KEY,
      clientId: CLIENT_ID,
      scope: "https://www.googleapis.com/auth/contacts",
    })
    await gapi.client.people.people.connections.list({
      'resourceName': 'people/me',
      'pageSize': 10,
      'personFields': 'names,emailAddresses',
    }).then(function(response) {
      console.log(response)
    })
  }

When I call gapi.client.people, it is undefined.

gapi.client gives me this object:

gapi.client returned object

Can anyone help me figure out how to debug this? Im doing what the tutorial indicates to do. My user is authenticated, I have waited for the api library to load, waited for gapi.client to initialize, but now when I ask for the gapi.client.people, nothing is there. How can I load this function?

1
  • In the future, please post a snippet of your code and not images, since it's harder to debug it this way.
    – Adrian Pop
    Commented Nov 17, 2018 at 9:48

2 Answers 2

2

You need to set the discoveryDocs parameter to People API discovery doc ["https://www.googleapis.com/discovery/v1/apis/people/v1/rest"] in order to get the People API loaded in GAPI. Please look at the documentation sample for an example of how to do this.

-1

I seem to get the same problem when my API key is invalid. Make sure that you're creating and using a separate API key and not accidentally using the client secret instead. Also, double check that your API key isn't restricted in any way in the its settings.

If you don't find any problems there, try regenerating your API key or making a new one. Let me know if you're still running into this problem! :)

Not the answer you're looking for? Browse other questions tagged or ask your own question.