Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Rack::OAuth2::Client Sample - Token Request

View token_request_sample.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
require 'rubygems'
require 'rack/oauth2'
 
client = Rack::OAuth2::Client.new(
:identifier => YOUR_CLIENT_ID,
:secret => YOUR_CLIENT_SECRET,
:redirect_uri => YOUR_REDIRECT_URI, # only required for grant_type = :code
:host => 'rack-oauth2-sample.heroku.com'
)
 
grant_type = :authorization_code
 
puts "## grant_type = :#{grant_type}"
 
case grant_type
when :client_credentials
# Nothing to do
when :password
client.resource_owner_credentials = YOUR_USERNAME, YOUR_PASSWORD
when :authorization_code
client.authorization_code = YOUR_AUTHORIZATION_CODE
when :refresh_token
client.refresh_token = YOUR_REFRESH_TOKEN_FOR_USER
end
 
begin
p client.access_token!
rescue => e
p e
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.