Skip to content

Instantly share code, notes, and snippets.

@kiall
Created August 23, 2011 08:54
Show Gist options
  • Save kiall/1164693 to your computer and use it in GitHub Desktop.
Save kiall/1164693 to your computer and use it in GitHub Desktop.
#!/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