Created
August 23, 2011 08:54
-
-
Save kiall/1164693 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'oauth2' | |
require 'pp' | |
client = OAuth2::Client.new('test', 'test', :site => 'http://localhost/', :authorize_url => 'http://localhost/oauth2/authorize', :token_url => 'http://localhost/oauth2/token') | |
puts client.auth_code.authorize_url(:redirect_uri => 'http://localhost/') | |
puts "And the code is?" | |
code = STDIN.gets.strip | |
begin | |
token = client.auth_code.get_token(code, :redirect_uri => 'http://localhost/') | |
pp token | |
rescue => e | |
pp e | |
exit | |
end | |
puts "..." | |
begin | |
response = token.get('http://localhost/test/ping', :params => { 'query_foo' => 'bar' }) | |
pp response | |
rescue => e | |
pp e | |
exit | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment