LinkedIn actually provides 2 APIs:

1. Initialize your linkedin api key and secret key

Linked in api key can be obtained from http://developer.linkedin.com/

2. Setting your callback:

callback_url = ‘http://localhost:3000/linkedin_callback’

3. Create oauth object

oauth = LinkedIn::Oauth.new(linkedin_api_key, linkedin_secret)

4. Request authorize url

oauth.request_token.authorize_url

=> “https://api.linkedin.com/uas/oauth/authorize?oauth_token=53bc5779-75fb-4a82-915c-a33dba1dddf2″

Open the link in your browser as redirection url for user to do authorization process, if user authorize it we will get params[:oauth_verifier] in our “callback_url”, use it to authorize from request.

for example:

http://localhost:3000/linkedin_callback?oauth_token=94145e28-2d4d-4d55-856d-c5e791334e09&oauth_verifier=00883

oauth_verifier = “00883″

authorize using oauth verifier and token

oauth.authorize_from_request(oauth.request_token.token, oauth.request_token.secret, oauth_verifier)

create linkedin api object

linkedin = LinkedIn::Base.new(oauth)

 
For any rails development & consulting services Hire rails developer from RailsCarma

Leave a Reply

Your email address will not be published.