问题
Do someone know how to add a new contact to my google account via python?
I didn't find how to do it in the reference: https://developers.google.com/google-apps/contacts/v3/reference
I want to add contact and I have only phone number and name.
Does someone know how to do it?
回答1:
I am writing down the steps and also adding some reference link, such that you will have better understanding
You can use
Google Oauth2to get access to the Google Contact and need to enableContact API and People APIGoogle Contact API
- Ref to Enable API: https://www.themarketingtechnologist.co/google-oauth-2-enable-your-application-to-access-data-from-a-google-user/
- Ref to Enable API: https://medium.com/@pablo127/google-api-authentication-with-oauth-2-on-the-example-of-gmail-a103c897fd98
- Need to enable People API - to work with contacts
- Enable: https://console.developers.google.com/apis/library/people.googleapis.com?
- Note: For read and write access to users' contacts, use the People API, which provides both contact and profile information using JSON instead of the older GData protocol.
Google Oauth2
- Google Consele > credentials > Web client 1 > Authorized redirect URIs >> Add
- To add and
Authorized redirect URIsthe domain must be added to the authorized domains list before submitting. - Google Consele > OAuth consent screen > Authorized domains >> Add Here
Action you can do after getting Google Contact access.
- Methods: https://developers.google.com/people/api/rest/
- CreateContact details: https://console.developers.google.com/apis/library/people.googleapis.com?project=contact-60659
- Get user data: https://developers.google.com/people/api/rest/v1/people.connections/list?apix_params=%7B"resourceName"%3A"people%2Fme"%2C"personFields"%3A"emailAddresses"%7D
NOTE: Please keep safe your Client_id, Secret_id and API key
来源:https://stackoverflow.com/questions/49300549/python-adding-contact-on-google-contacts