module LinkedIn::Helpers::Authorization
Constants
- DEFAULT_OAUTH_OPTIONS
Public Instance Methods
access_token()
click to toggle source
# File lib/linked_in/helpers/authorization.rb, line 33 def access_token @access_token ||= ::OAuth2::AccessToken.new(consumer, @auth_token, :expires_at => @expires_at) end
consumer()
click to toggle source
# File lib/linked_in/helpers/authorization.rb, line 14 def consumer @consumer ||= ::OAuth2::Client.new(@consumer_token, @consumer_secret, parse_oauth_options) end
request_token(options={}, *arguments, &block)
click to toggle source
Note: If using oauth with a web app, be sure to provide :oauth_callback. Options:
:oauth_callback => String, url that LinkedIn should redirect to
# File lib/linked_in/helpers/authorization.rb, line 21 def request_token(options={}, *arguments, &block) @request_token ||= consumer.get_request_token(options, *arguments, &block) end
Private Instance Methods
full_oauth_url_for(url_type, host_type)
click to toggle source
# File lib/linked_in/helpers/authorization.rb, line 56 def full_oauth_url_for(url_type, host_type) if @consumer_options["#{url_type}_url".to_sym] @consumer_options["#{url_type}_url".to_sym] else host = @consumer_options[:site] || @consumer_options[host_type] || DEFAULT_OAUTH_OPTIONS[host_type] path = @consumer_options[:"#{url_type}_path".to_sym] || DEFAULT_OAUTH_OPTIONS["#{url_type}_path".to_sym] "#{host}#{path}" end end
parse_oauth_options()
click to toggle source
since LinkedIn
uses api.linkedin.com for request and access token exchanges, but www.linkedin.com for authorize/authenticate, we have to take care of the url creation ourselves.
# File lib/linked_in/helpers/authorization.rb, line 46 def parse_oauth_options { #:request_token_url => full_oauth_url_for(:request_token, :api_host), :access_token_url => full_oauth_url_for(:access_token, :api_host), :authorize_url => full_oauth_url_for(:authorize, :auth_host), :site => @consumer_options[:site] || @consumer_options[:api_host] || DEFAULT_OAUTH_OPTIONS[:api_host], :proxy => @consumer_options.fetch(:proxy, nil) } end