This script will go through all your Google Contacts and list the contacts without a phone number and ask if you want to delete those contacts.
This script was created because there is no way in the Google Contacts website to filter contacts to only show ones without a phone number. So it is currently a manual process. This script allows you to delete those contacts in batches.
Because the script works in batches it might take multiple batches to delete those contacts. The script will show you how many it will delete in the current batch out of the total contacts found without a phone number.
To get started using the Google People API, you need to first use the setup tool, which guides you through creating a project in the Google API Console, enabling the API, and creating credentials.
On the credentials page, provide these answers:
- Which API are you using? People API
- Where will you be calling the API from? Web Browser (Javascript)
- What data will you be accessing? User data
For more instructions visit https://developers.google.com/people/v1/getting-started
- Go to the Credentials page.
- Click Create credentials > OAuth client ID.
- Select the Web application application type.
- For Authorized JavaScript origins enter
http://localhost:8080
. - For Authorized redirect URIs enter
http://localhost:8080
. - Click Create.
- After creating your credentials, download the client_secret.json file from the API Console (using the download icon on the right).
- Move the file into this current directory (all
client_secret*.json
files in this directory are Git-ignored)
For more instructions visit https://developers.google.com/identity/protocols/oauth2/web-server#creatingcred
Note: When authenticating with your Google account, it will redirect to a page that can't be reached. This is because the script is not running on a web server. Do not exit the browser, the authorization code is the part of the current URL between ?code=
and &scope=
. The script will prompt you to enter that code.
-
Change to the current directory (if not in it already)
cd google_api_delete_contacts_with_no_phone
-
Build the docker image
docker build -t google_api_delete_contacts_with_no_phone .
-
Run the docker container
docker run -it --rm google_api_delete_contacts_with_no_phone
-
Set up and activate a python virtual environment
-
Change to the current directory (if not in it already)
cd google_api_delete_contacts_with_no_phone
-
Install the requirements
pip install -r requirements.txt
-
Run the script
python google_api_delete_contacts_with_no_phone.py