Skip to content

Instantly share code, notes, and snippets.

@chadwilken
Created December 11, 2018 16:06
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 chadwilken/f592395f028bd7a7ca923e04db6e7446 to your computer and use it in GitHub Desktop.
Save chadwilken/f592395f028bd7a7ca923e04db6e7446 to your computer and use it in GitHub Desktop.
OAuth 2 Flow
client = OAuth2::Client.new(ENV['COMPANYCAM_UID'], ENV['COMPANYCAM_SECRET'], site: 'https://app.companycam.com')
# Get a auth URL to redirect user to
client.auth_code.authorize_url(redirect_uri: 'https://yoursite.com/oauth/companycam/callback')
# The user will accept of deny and then be redirected to the URL above
# the URL will have a parameter `code` if the user accepted.
# You will take the code and POST back to exchange for an access_token and refresh_token
client.auth_code.get_token(params[:code], redirect_uri: 'https://yoursite.com/oauth/companycam/callback')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment