Skip to content

Instantly share code, notes, and snippets.

@nov
Created March 9, 2011 15:30
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save nov/862393 to your computer and use it in GitHub Desktop.
Save nov/862393 to your computer and use it in GitHub Desktop.
Rack::OAuth2::Client Sample - Authorization Request
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'
)
request_type = :token
puts "## request_type = :#{request_type}"
authorization_uri = case request_type
when :code
client.authorization_uri(:scope => :user_about_me)
when :token
client.authorization_uri(:response_type => :token, :scope => :user_about_me)
end
puts authorization_uri
@zhangyuxiu
Copy link

I don't know how to use and test the client sample. In order to exec the example above, I must have the consts: YOUR_CLIENT_ID,YOUR_CLIENT_SECRET and so on. But where should I register and get the values.

@Liutos
Copy link

Liutos commented Jan 29, 2013

@zhangyuxiu You need a OAuth 2.0 provider, which can be built by rack-oauth2 or any other OAuth2 provider libraries. For example, you can use the Doorkeeper or devise_oauth2_providable.

@pkaeding
Copy link

pkaeding commented Aug 5, 2014

I must be missing something here; isn't rack-oauth2-sample.heroku.com meant to be an OAuth 2.0 provider? How do we use this example client code with that reference implementation using the rack-oauth2 library?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment