Skip to content

Instantly share code, notes, and snippets.

@ukyo
Created August 30, 2012 03:27
Show Gist options
  • Save ukyo/3522018 to your computer and use it in GitHub Desktop.
Save ukyo/3522018 to your computer and use it in GitHub Desktop.
github oauth2 flow

#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];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment