Class: LinkedinToken

Inherits:
ConsumerToken
  • Object
show all
Defined in:
lib/muck_oauth/services/linkedin_token.rb

Constant Summary collapse

LINKEDIN_SETTINGS =
{
  :site => "https://api.linkedin.com", 
  :request_token_path => "/uas/oauth/requestToken",
  :access_token_path  => "/uas/oauth/accessToken",
  :authorize_path     => "/uas/oauth/authorize"
}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.consumerObject


11
12
13
# File 'lib/muck_oauth/services/linkedin_token.rb', line 11

def self.consumer
  @consumer ||= create_consumer
end

.create_consumer(options = {}) ⇒ Object


15
16
17
# File 'lib/muck_oauth/services/linkedin_token.rb', line 15

def self.create_consumer(options={})
  OAuth::Consumer.new(credentials[:key], credentials[:secret], LINKEDIN_SETTINGS.merge(options))
end

.get_request_token(callback_url) ⇒ Object


19
20
21
# File 'lib/muck_oauth/services/linkedin_token.rb', line 19

def self.get_request_token(callback_url)
  consumer.get_request_token({ :oauth_callback => callback_url })
end

Instance Method Details

#clientObject


23
24
25
26
27
28
29
# File 'lib/muck_oauth/services/linkedin_token.rb', line 23

def client
  unless @client
    @client = ::LinkedIn::Client.new(LinkedinToken.consumer.key, LinkedinToken.consumer.secret)
    @client.authorize_from_access(token, secret)
  end 
  @client
end