Search code examples
pythongoogle-people-api

Google People API as a Worker/CLI


I'm trying to use Google People API as a python worker (with celery) so this is not a webapp (I'm using the python libraries suggested in their documentation (google-api-python-client, google-auth-httplib2 and google-auth-oauthlib).

So I'd like to use the API keys to access to the API and I can not find any documentation about using in this way and what limitations will have or anything.

I didn't find anyone asking this question before.


Solution

  • Depends on how you're calling the APIs. I advise to use the library for Google APIs.

    It seems that the People API is not listed in the APIs available through the Google Cloud APIs here.
    NOTE: you should use that library if the API in question is available there.

    The google-api-python-client has a description on how to use API keys here, but to put it simply, build the service object using the key.

    service = build('people', 'v1', developerKey='YOUR_API_KEY_HERE')
    

    If you're calling the People API using fe. the requests library (eg. basic normal HTTP call) then just append key=YOUR_API_KEY_HERE to the URL for the request, as per documentation found here.

    NOTE

    If you're trying to access private data, you simply cannot do this with an API key. (Otherwise you would be able to harvest all contact emails from fe. Sundar Pichai). You need the consent (and therefore need to use OAuth2.0) to access private data...