Skip to content

Instantly share code, notes, and snippets.

@markoa
Created August 17, 2011 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markoa/1151676 to your computer and use it in GitHub Desktop.
Save markoa/1151676 to your computer and use it in GitHub Desktop.
Sample wrapper around linkedin gem to support varying user credentials.
# See https://gist.github.com/1151655 for a tip how to save access token and secret in an omniauth callback.
class LinkedinFactory
API_KEY = "123"
SECRET_KEY = "456"
def self.authorize_user(user)
token = user.linkedin_connection.token
secret = user.linkedin_connection.secret
client = LinkedIn::Client.new(API_KEY, SECRET_KEY)
client.authorize_from_access(token, secret)
client
end
# now every API call would look like this:
def self.get_connections(user)
client = self.authorize_user(user)
client.connections(:fields => ["id", "first-name", "last-name"])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment