Class: OmniAuth::Strategies::Liveid
- Defined in:
- lib/omniauth/strategies/oauth2/liveid.rb
Overview
Authenticate to Windows Connect utilizing OAuth 2.0 and retrieve basic user information.
OAuth 2.0 - MS Documentation http://msdn.microsoft.com/en-us/library/hh243647.aspx
Sign-up for account: http://go.microsoft.com/fwlink/?LinkId=213332
Instance Attribute Summary
Attributes inherited from OAuth2
#client_id, #client_options, #client_secret, #options
Instance Method Summary collapse
- #auth_hash ⇒ Object
-
#initialize(app, client_id = nil, client_secret = nil, options = {}, &block) ⇒ Liveid
constructor
A new instance of Liveid.
- #request_phase ⇒ Object
- #user_data ⇒ Object
- #user_info ⇒ Object
Methods inherited from OAuth2
Constructor Details
#initialize(app, client_id = nil, client_secret = nil, options = {}, &block) ⇒ Liveid
Returns a new instance of Liveid.
20 21 22 23 24 25 26 27 |
# File 'lib/omniauth/strategies/oauth2/liveid.rb', line 20 def initialize(app, client_id=nil, client_secret=nil, ={}, &block) = { :authorize_url => 'https://oauth.live.com/authorize', :token_url => 'https://oauth.live.com/token' } super(app, :liveid, client_id, client_secret, , , &block) end |
Instance Method Details
#auth_hash ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/omniauth/strategies/oauth2/liveid.rb', line 29 def auth_hash OmniAuth::Utils.deep_merge( super, { 'uid' => user_data['id'], 'user_info' => user_info, 'extra' => { 'user_hash' => user_data, } } ) end |
#request_phase ⇒ Object
42 43 44 45 46 |
# File 'lib/omniauth/strategies/oauth2/liveid.rb', line 42 def request_phase [:scope] ||= 'wl.signin wl.basic' [:response_type] ||= 'code' super end |
#user_data ⇒ Object
48 49 50 |
# File 'lib/omniauth/strategies/oauth2/liveid.rb', line 48 def user_data @data ||= MultiJson.decode(@access_token.get('https://apis.live.net/v5.0/me').body) end |
#user_info ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/omniauth/strategies/oauth2/liveid.rb', line 52 def user_info { 'id' => user_data['id'], 'name' => user_data['name'], 'email' => '', 'first_name' => user_data['first_name'], 'last_name' => user_data['last_name'], 'link' => user_data['link'], 'gender' => user_data['gender'], 'locale' => user_data['locale'] } end |