Skip to content

Instantly share code, notes, and snippets.

@kamloops
kamloops / gist:7473377
Created November 14, 2013 20:01
LinkedIn OAuth2 flow with POST to /accessToken
def index
authorize_oauth2
end
def authorize_oauth2
# Redirect to /authorization endpoint
redirect_to client.auth_code.authorize_url(:state => 'thisisatest', :redirect_uri => REDIRECT_URI)
end
def accept
@kamloops
kamloops / gist:7439946
Last active December 28, 2015 04:09
simple oauth 1.0a example
require 'oauth'
# Fill the keys and secrets you retrieved after registering your app
api_key = 'abcd123456'
api_secret = 'efgh987654'
user_token = 'abcd1234-efgh987-9988'
user_secret = '9876abcd-123asdf-1122'
# Specify LinkedIn API endpoint
configuration = { :site => 'https://www.linkedin.com' }
@kamloops
kamloops / linkedin_oauth2_sample.rb
Last active April 19, 2017 06:01
Simple LinkedIn OAuth2 authentication
require 'oauth2'
require 'net/http'
require 'uri'
API_KEY = 'XXXXXXXXX' #Your app's API key
API_SECRET = 'XXXXXXXXXXXXX' #Your app's API secret
REDIRECT_URI = 'http://localhost:3000/accept' #Redirect users after authentication to this path
#Instantiate your OAuth2 client object
def client