Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loicginoux/f70dc6e6a8843c22ce29 to your computer and use it in GitHub Desktop.
Save loicginoux/f70dc6e6a8843c22ce29 to your computer and use it in GitHub Desktop.
testing authorisation flow with doorkeeper
require 'oauth2'
client_id = '...'
client_secret = '...'
redirect_uri = "urn:ietf:wg:oauth:2.0:oob"
site = "http://localhost:3000"
client = OAuth2::Client.new(client_id, client_secret, :site => site)
# client.auth_code.authorize_url(:redirect_uri => redirect_uri)
# code you got in the redirect uri
code = "78825a38ad01a66e381b621538a1fdc7cf25a11dff0bfb59539a68380781d83d"
token = client.auth_code.get_token(code, :redirect_uri => redirect_uri)
p "access token is: #{token.token}"
p "you can use it by doing a GET to the url:"
p "#{site}/api/v2/projects?access_token=#{token.token}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment