Fork me on GitHub
07 April 2013

Authorisations Tool

Enter in your username, password, and the scopes you want the oAuth token to cover, along with a note so that you know what this oAuth is for, y'know, it's handy. I can assure that this code does not save the password anywhere and merely uses it to log into GitHub and set up a new authorisation token. If you want to check it out, the code for this is in the gist below (I'm using the gist as the hosting for the script too, just so you can be 100% sure there's no funny business). There is a bit of Google Analytics event tracking, purely for my own curiosity as to how much it is used, but it doesn't track anything except for the fact that it is being used, if it succeeds, or if it fails.

GitHub Authorisations API
GitHub API Scopes
GitHub Authorisations Response

Fill 'er in!

Fill in the form to the left, and we'll get right on the job.


The story...

In recent months i've had many occasions where I've needed to use the GitHub API, for both personal projects and under the aegis of stuff i've done for work. The main obstical I've had is that if you're building a command line tool, as I usually do for these things, there isn't a nice way to get an oAuth token, like there is for a web app.

As I'm sure you're aware when you're using oAuth with a web app, you get forewarded to a nice GitHub login page where you accept/deny the request to allow the application access to your github account. This isn't really possible when what you're doing is a command line tool. Moreover when you're building a tool that is only going to be used by yourself, or by a small closed set of developers, you don't really need that added niceness layer, you just need the oAuth access token so you can get on with what you need to do.

Fortunately GitHub have an API method that is just the solution to this, it's the authorisations API, where you can pass a username and a password to get an oAuth token in return, handily meaning you don't have to store the users password in some plain text.

Here's the code for a Flatiron.js command script that I have used to generate my oAuth tokens, it depends upon my githubber node.js github api library.

As you can see; it's a pretty simple script.

However it still requires having it set up on a server or my computer, and using the command line, and blargh - that just doesn't make me happy when it comes to a usability. Plus I figured that other people have a similar problem, and I wanted to try out some cool dynamic cross-server javascript coding on gitHub Pages.

So. You know. There's that.


The Code...


Related Posts They might not be good...

Categories

Tags


blog comments powered by Disqus