Search code examples
pythongoogle-people-api

People API google - Add contact from python script


I just need to create a contact (name and phone number) to my own google account from console (python script, not UI).

Can I do that?

I am following this guide: https://github.com/gsuitedevs/python-samples/tree/master/people/quickstart

The problem is that a new chrome window open to redirect somewhere.. I pretend to use this in a server with no UI.


Solution

  • Yes, you can!

    I used this code: https://gist.github.com/samkit5495/ff8e2a6644363cadaec3fa22ddf38c90

    First of all, you have to create an OAuth 2.0 key: https://console.developers.google.com/apis

    Important: URI redirect, I was getting an error 400 "localhost:8080/"... You have to put the exact same url with "/" at the end...

    Download the key and put it in the same dir as the script in a file called client_secret.json

    Execute the script and then a browser will open, then put your google account and that's it!