Last active
December 28, 2015 04:09
-
-
Save kamloops/7439946 to your computer and use it in GitHub Desktop.
simple oauth 1.0a example
This file contains hidden or 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 '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' } | |
# Use your API key and secret to instantiate consumer object | |
consumer = OAuth::Consumer.new(api_key, api_secret, configuration) | |
# Use your developer token and secret to instantiate access token object | |
access_token = OAuth::AccessToken.new(consumer, user_token, user_secret) | |
# Make call to LinkedIn to retrieve your own profile | |
response = access_token.get("http://api.linkedin.com/v1/people/~") | |
# By default, the LinkedIn API responses are in XML format. If you prefer JSON, simply specify the format in your call | |
# response = access_token.get("http://api.linkedin.com/v1/people/~?format=json") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment