Skip to content

Instantly share code, notes, and snippets.

@olvap
Last active August 29, 2015 13:57
Show Gist options
  • Select an option

  • Save olvap/9841929 to your computer and use it in GitHub Desktop.

Select an option

Save olvap/9841929 to your computer and use it in GitHub Desktop.
require 'oauth2'
client_id = "2991b1d948ba1aed69144fb3a34474216d6a374cb876f02d51a2f40d3b783bd3"
secret_client = "d528cf49d607b476ea27b9c662615b50b29605cb5151626bc378948606e60149"
redirect_uri = "http://localhost:3000"
site = "http://lutron.herokuapp.com/"
client = OAuth2::Client.new(client_id, client_secret, :site => site)
client.auth_code.authorize_url(:redirect_uri => redirect_uri)
# => http://localhost:3000/oauth/authorize?response_type=code&client_id=...&redirect_uri=...
#Go to this url in your browser. You'll see the authorization endpoint. If you click on Authorize, you'll see a page with #the authorization code in it:
code = "..." # code you got in the redirect uri
token = client.auth_code.get_token(code, :redirect_uri => redirect_uri)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment