#get client id
go to here and create app.
#authorize
//set a uuid.
localStorage.state = createUUID();
//go to the authorize page.
location.href = 'https://github.com/login/oauth/authorize?client_id=' + clientId + '&state=' + localStorage.state;
you get a code after authorize.
var code = location.href.match(/code=([^?]+)/)[1];