A tool to talk to google to allow you to use your google contacts from within mutt. You don’t store your password on disk, you store oauth2 info, so you’re not exposing your password your google identity to your friends, family, or co-workers. Or your sysadmin.
I’m proudly helping to keep you mired in the pre-web 1.0 days, by enhancing your antiquated neckbeard email client with the most ho-hum of cloud contact technology.
Register yourself with google to use their oauth2 api from your very own private console (which could be your laptop)
The interface to it will be command-line based, similar to abook, goobook, etc.
The workflow will be:
* execute ** if there is an auth token that exists on disk already in ~/.gonetact/client.json, use it. *** Connect to google's auth API and do the oauth2 dance to get contacts API access [done] **** display a URL to go to which will then ask you to auth to google. **** get the oauth token and enter it into the provided prompt **** save it to ~/.gonetact/cache.json *** Provide commands to: **** Get all contacts [done, default behavior] **** add a contact (deletes will be up to the web UI for now)
Log into your google account, and point it to https://console.developers.google.com/project.
If this is the first time you’ve used this feature, you should see an empty pane prompting you to create a new project, something like this:
Click on the red "Create Project" button, and create a project called "gonetact" without the quotes:
The second field, the "project ID" will be generated randomly by the server. You shouldn’t accept what it provides.
Give it a minute to create, and you should see a screen that looks like this:
Click on the "APIs & auth" item on the top left, and then click on the APIs item. Scroll down until you see the "Contacts API" and click the "Off" button:
and turn it "On". The following dialog will appear. Click on and agree to the terms of service (unless you disagree, in which case you can turn around now):
Now click the "Accept" button. After a moment the list of APIs will re-order themselves, and the contacts will appear towards the top of the list.
Next click on the "Credentials" sub-heading of the "APIs & auth" section, and you’ll see a red "Create New Client ID" button.
you’ll get a dialog to select the type of key, choose "Installed Application", and leave the "Installed Application Type" at the "other" button.
and click the "Create Client ID" button.
Now, click the "Download JSON" button in the "Client ID for native application" section.
Download that file and save it in the directory \~/.gonetact as ~/.gonetact/client.json
First gonetact has the following dependencies that you need to install:
go get github.com/docopt/docopt-go go get code.google.com/p/goauth2
After you’ve done that, you should be able to run "go build" and then place the resulting binary in your $PATH.
Make sure you have a directory called ~/.gonetact, and put your client.json there.
Now, run
gonetact
for the first time. It will attempt to launch the authentication screen in your browser.
If you’re ssh’d into another system, one that doesn’t have a local browser, you can have gonetact print out the URL that you need to visit to authenticate
gonetact --no-browser
If you do this, then copy the URL to a browser that’s logged into the account whose contacts you want to access, and approve the access. At the end of the process, you will need to copy the code that google provides into your terminal window and paste it into gonetact. With that, it’ll cache the code, and it’ll be able to access your contacts.
In your ~/.muttrc, make sure the following lines added:
set alias_file=~/.mutt-alias source ~/.mutt-alias set query_command = "~/bin/gonetact --query '%s'"
If you don’t have a file called ~/.mutt-alias, create it now
touch ~/.mutt-alias
If you put the goneact program into another location, then change the last tline added to your .muttrc to reflect the location where you installed it.
-
Look at other similar clients to see if they have a convention in the contacts where they store lookup info for aliases.
-
The code is ugly. Learn better practices
-
Put the client config and the cache into ~/.gonetacts instead of $PWD
-
Added tests
-
filter contacts with a simple substring match
-
pop up a browser by default (thanks @rce)
-
Write up a better intro to how to get your google API to allow you to do alias updates
-
Write a section on how to configure mutt