Module: Sorcery::Controller::Submodules::External::Providers::Linkedin::LinkedinClient
- Defined in:
- lib/sorcery/controller/submodules/external/providers/linkedin.rb
Class Attribute Summary collapse
-
.access_permissions ⇒ Object
Returns the value of attribute access_permissions.
-
.access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
.access_token_path ⇒ Object
Returns the value of attribute access_token_path.
-
.authorize_path ⇒ Object
Returns the value of attribute authorize_path.
-
.callback_url ⇒ Object
Returns the value of attribute callback_url.
-
.key ⇒ Object
Returns the value of attribute key.
-
.request_token_path ⇒ Object
Returns the value of attribute request_token_path.
-
.secret ⇒ Object
Returns the value of attribute secret.
-
.site ⇒ Object
Returns the value of attribute site.
-
.user_info_fields ⇒ Object
Returns the value of attribute user_info_fields.
-
.user_info_mapping ⇒ Object
Returns the value of attribute user_info_mapping.
-
.user_info_path ⇒ Object
Returns the value of attribute user_info_path.
Class Method Summary collapse
-
.get_consumer ⇒ Object
Override included get_consumer method to provide authorize_path.
- .get_user_hash ⇒ Object
- .has_callback? ⇒ Boolean
- .init ⇒ Object
-
.login_url(params, session) ⇒ Object
calculates and returns the url to which the user should be redirected, to get authenticated at the external provider’s site.
-
.process_callback(params, session) ⇒ Object
tries to login the user from access token.
Methods included from Sorcery::Controller::Submodules::External::Protocols::Oauth1
authorize_url, get_access_token, get_request_token, oauth_version
Class Attribute Details
.access_permissions ⇒ Object
Returns the value of attribute access_permissions.
31 32 33 |
# File 'lib/sorcery/controller/submodules/external/providers/linkedin.rb', line 31 def @access_permissions end |
.access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
42 43 44 |
# File 'lib/sorcery/controller/submodules/external/providers/linkedin.rb', line 42 def access_token @access_token end |
.access_token_path ⇒ Object
Returns the value of attribute access_token_path.
31 32 33 |
# File 'lib/sorcery/controller/submodules/external/providers/linkedin.rb', line 31 def access_token_path @access_token_path end |
.authorize_path ⇒ Object
Returns the value of attribute authorize_path.
31 32 33 |
# File 'lib/sorcery/controller/submodules/external/providers/linkedin.rb', line 31 def @authorize_path end |
.callback_url ⇒ Object
Returns the value of attribute callback_url.
31 32 33 |
# File 'lib/sorcery/controller/submodules/external/providers/linkedin.rb', line 31 def callback_url @callback_url end |
.key ⇒ Object
Returns the value of attribute key.
31 32 33 |
# File 'lib/sorcery/controller/submodules/external/providers/linkedin.rb', line 31 def key @key end |
.request_token_path ⇒ Object
Returns the value of attribute request_token_path.
31 32 33 |
# File 'lib/sorcery/controller/submodules/external/providers/linkedin.rb', line 31 def request_token_path @request_token_path end |
.secret ⇒ Object
Returns the value of attribute secret.
31 32 33 |
# File 'lib/sorcery/controller/submodules/external/providers/linkedin.rb', line 31 def secret @secret end |
.site ⇒ Object
Returns the value of attribute site.
31 32 33 |
# File 'lib/sorcery/controller/submodules/external/providers/linkedin.rb', line 31 def site @site end |
.user_info_fields ⇒ Object
Returns the value of attribute user_info_fields.
31 32 33 |
# File 'lib/sorcery/controller/submodules/external/providers/linkedin.rb', line 31 def user_info_fields @user_info_fields end |
.user_info_mapping ⇒ Object
Returns the value of attribute user_info_mapping.
31 32 33 |
# File 'lib/sorcery/controller/submodules/external/providers/linkedin.rb', line 31 def user_info_mapping @user_info_mapping end |
.user_info_path ⇒ Object
Returns the value of attribute user_info_path.
31 32 33 |
# File 'lib/sorcery/controller/submodules/external/providers/linkedin.rb', line 31 def user_info_path @user_info_path end |
Class Method Details
.get_consumer ⇒ Object
Override included get_consumer method to provide authorize_path
47 48 49 50 51 |
# File 'lib/sorcery/controller/submodules/external/providers/linkedin.rb', line 47 def get_consumer # Add access permissions to request token path @configuration[:request_token_path] += "?scope=" + self..join('+') unless self..blank? or @configuration[:request_token_path].include? "?scope=" ::OAuth::Consumer.new(@key, @secret, @configuration) end |
.get_user_hash ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/sorcery/controller/submodules/external/providers/linkedin.rb', line 63 def get_user_hash user_hash = {} fields = self.user_info_fields.join(',') response = @access_token.get("#{@user_info_path}:(#{fields})", 'x-li-format' => 'json') user_hash[:user_info] = JSON.parse(response.body) user_hash[:uid] = user_hash[:user_info]['id'].to_s user_hash end |
.has_callback? ⇒ Boolean
72 73 74 |
# File 'lib/sorcery/controller/submodules/external/providers/linkedin.rb', line 72 def has_callback? true end |
.init ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/sorcery/controller/submodules/external/providers/linkedin.rb', line 53 def init @configuration = { site: "https://api.linkedin.com", authorize_path: '/uas/oauth/authenticate', request_token_path: '/uas/oauth/requestToken', access_token_path: '/uas/oauth/accessToken' } @user_info_path = "/v1/people/~" end |
.login_url(params, session) ⇒ Object
calculates and returns the url to which the user should be redirected, to get authenticated at the external provider’s site.
78 79 80 81 82 83 |
# File 'lib/sorcery/controller/submodules/external/providers/linkedin.rb', line 78 def login_url(params,session) req_token = self.get_request_token session[:request_token] = req_token.token session[:request_token_secret] = req_token.secret self.({:request_token => req_token.token, :request_token_secret => req_token.secret}) end |
.process_callback(params, session) ⇒ Object
tries to login the user from access token
86 87 88 89 90 91 |
# File 'lib/sorcery/controller/submodules/external/providers/linkedin.rb', line 86 def process_callback(params,session) args = {} args.merge!({:oauth_verifier => params[:oauth_verifier], :request_token => session[:request_token], :request_token_secret => session[:request_token_secret]}) args.merge!({:code => params[:code]}) if params[:code] @access_token = self.get_access_token(args) end |