Module: Sorcery::Controller::Submodules::External::Providers::Liveid::LiveidClient
- Defined in:
- lib/sorcery/controller/submodules/external/providers/liveid.rb
Class Attribute Summary collapse
-
.access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
.auth_url ⇒ Object
Returns the value of attribute auth_url.
-
.callback_url ⇒ Object
Returns the value of attribute callback_url.
-
.key ⇒ Object
Returns the value of attribute key.
-
.scope ⇒ Object
Returns the value of attribute scope.
-
.secret ⇒ Object
Returns the value of attribute secret.
-
.site ⇒ Object
Returns the value of attribute site.
-
.token_path ⇒ Object
Returns the value of attribute token_path.
-
.user_info_mapping ⇒ Object
Returns the value of attribute user_info_mapping.
-
.user_info_url ⇒ Object
Returns the value of attribute user_info_url.
Class Method Summary collapse
- .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::Oauth2
authorize_url, build_client, get_access_token, oauth_version
Class Attribute Details
.access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
40 41 42 |
# File 'lib/sorcery/controller/submodules/external/providers/liveid.rb', line 40 def access_token @access_token end |
.auth_url ⇒ Object
Returns the value of attribute auth_url.
31 32 33 |
# File 'lib/sorcery/controller/submodules/external/providers/liveid.rb', line 31 def auth_url @auth_url end |
.callback_url ⇒ Object
Returns the value of attribute callback_url.
31 32 33 |
# File 'lib/sorcery/controller/submodules/external/providers/liveid.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/liveid.rb', line 31 def key @key end |
.scope ⇒ Object
Returns the value of attribute scope.
31 32 33 |
# File 'lib/sorcery/controller/submodules/external/providers/liveid.rb', line 31 def scope @scope end |
.secret ⇒ Object
Returns the value of attribute secret.
31 32 33 |
# File 'lib/sorcery/controller/submodules/external/providers/liveid.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/liveid.rb', line 31 def site @site end |
.token_path ⇒ Object
Returns the value of attribute token_path.
31 32 33 |
# File 'lib/sorcery/controller/submodules/external/providers/liveid.rb', line 31 def token_path @token_path end |
.user_info_mapping ⇒ Object
Returns the value of attribute user_info_mapping.
31 32 33 |
# File 'lib/sorcery/controller/submodules/external/providers/liveid.rb', line 31 def user_info_mapping @user_info_mapping end |
.user_info_url ⇒ Object
Returns the value of attribute user_info_url.
31 32 33 |
# File 'lib/sorcery/controller/submodules/external/providers/liveid.rb', line 31 def user_info_url @user_info_url end |
Class Method Details
.get_user_hash ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/sorcery/controller/submodules/external/providers/liveid.rb', line 53 def get_user_hash user_hash = {} @access_token.token_param = "access_token" response = @access_token.get(@user_info_url) user_hash[:user_info] = JSON.parse(response.body) user_hash[:uid] = user_hash[:user_info]['id'] user_hash end |
.has_callback? ⇒ Boolean
62 63 64 |
# File 'lib/sorcery/controller/submodules/external/providers/liveid.rb', line 62 def has_callback? true end |
.init ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/sorcery/controller/submodules/external/providers/liveid.rb', line 44 def init @site = "https://oauth.live.com/" @auth_url = "/authorize" @token_path = "/token" @user_info_url = "https://apis.live.net/v5.0/me" @scope = "wl.basic wl.emails wl.offline_access" @user_info_mapping = {} 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.
68 69 70 |
# File 'lib/sorcery/controller/submodules/external/providers/liveid.rb', line 68 def login_url(params,session) self.({:authorize_url => @auth_url}) end |
.process_callback(params, session) ⇒ Object
tries to login the user from access token
73 74 75 76 77 78 79 80 81 |
# File 'lib/sorcery/controller/submodules/external/providers/liveid.rb', line 73 def process_callback(params,session) args = {} args.merge!({:code => params[:code]}) if params[:code] = { :access_token_path => @token_path, :access_token_method => :post } @access_token = self.get_access_token(args, ) end |