Created
December 9, 2013 23:33
-
-
Save maxwellE/7883066 to your computer and use it in GitHub Desktop.
Gumroad OAuth2 sample code, uses the OAuth2 Gem https://github.com/intridea/oauth2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'oauth2' | |
client = OAuth2::Client.new('client_id', 'client_secret', :site => 'https://example.org') | |
client.auth_code.authorize_url(:redirect_uri => 'http://localhost:8080/oauth2/callback') | |
# => "https://example.org/oauth/authorization?response_type=code&client_id=client_id&redirect_uri=http://localhost:8080/oauth2/callback" | |
token = client.auth_code.get_token('authorization_code_value', :redirect_uri => 'http://localhost:8080/oauth2/callback', :headers => {'Authorization' => 'Basic some_password'}) | |
response = token.get('/api/resource', :params => { 'query_foo' => 'bar' }) | |
response.class.name | |
# => OAuth2::Response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment