After playing around a bit with this I'm not sure if this will be ideal in all cases. It seems using this with Google URL Shortener will then mean access tokens can expire after a minute and will need to be refreshed. I'll have a look at how the refresh flow works and see if it's viable. Otherwise, I'll only be implementing this partially to support bitly, if it works for that.
Also, it appears not to callback if the OAuth fails or the flow is broken (e.g. user cancels/closes tab), meaning the login button doesn't revert back to its enabled. This was the same for the current implementation but was easily tweaked so I'll need to see if the same can be done for this.
Finally, there seems to be a problem with setting up bitly applications right now so I won't really be able to test this properly yet.
To refresh tokens I just need to call
To make using this framework easier I'm probably going to fork it and make the following changes;