I have been working on a long needed update to the Google analytics dashboard plugin for WordPress and one of the items I had on my TODO list was using Google’s OAuth login instead of the old ClientLogin. Setting OAuth up for a WordPress plugin is complicated because it isn’t a hosted application and as such I can’t register it to get OAuth keys. That is where a special way of doing OAuth comes in called OAuth for installed apps.
There seems to be a lot of general documentation on how to do OAuth but there wasn’t much about using it for installed apps so what follows is an example using PHP that is basically what went into the plugin update.