Skip to content

Instantly share code, notes, and snippets.

@paulwalker
Created July 21, 2011 19:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulwalker/1097994 to your computer and use it in GitHub Desktop.
Save paulwalker/1097994 to your computer and use it in GitHub Desktop.
oauth2 => github example
require 'rubygems'; require 'spec/helper'; Faraday.default_adapter = :net_http
args = { :site => 'https://api.github.com', :authorize_url => 'https://github.com/login/oauth/authorize', :token_url => 'https://github.com/login/oauth/access_token', :ssl => { :verify => false } }
client = OAuth2::Client.new('9deeb74498c897efa13e', '5b40e74810edd50ebe24770a5f2dcd389d687c73', args)
redirect_uri = 'https://github.com/paulwalker/oauth2'
client.auth_code.authorize_url(:redirect_uri => redirect_uri)
# navigate to domain in browser and then put code value in
code = ''
begin; token = client.auth_code.get_token(code, :redirect_uri => redirect_uri); rescue Exception => e; end
response = token.get('/user')
response.parsed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment