Marko Anastasov wrote this on August 17, 2011

How to use linkedin gem with Omniauth

Say you want to use the linkedin gem as an interface to the LinkedIn API, but you can’t do what it says in the README, because you want your user to authenticate with Omniauth’s LinkedIn strategy. The solution is to save your user’s access token and secret that you receive in the OAuth callback action, and use them to access the API.

Assuming that a LinkedinConnection model belongs to User, in your controller you might write:

Now whenever you need to make a call to the API, you first need to make a new LinkedIn::Client object using the saved token and secret:

comments powered by Disqus

About Marko Anastasov

Rendered Text co-founder. Started with code, currently more focused on people and words. Foosball striker and entry-level cyclist.

Suggested Reads

Rails Testing Handbook

A new ebook on building test-driven Rails apps with RSpec and Cucumber.

At Rendered Text, we have a long history with Ruby on Rails. Checking the blog archive reminds me that we published first posts about working with Rails way back in 2009.

———

Rendered Text is a software company. For questions regarding Semaphore, please visit semaphoreci.com. Otherwise, feel free to get in touch any time by sending us an email.