Created
July 21, 2011 19:34
-
-
Save paulwalker/1097994 to your computer and use it in GitHub Desktop.
oauth2 => github example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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