Class: OmniAuth::Strategies::Doit
- Defined in:
- lib/omniauth/strategies/oauth2/doit.rb
Instance Attribute Summary
Attributes inherited from OAuth2
#client_id, #client_options, #client_secret, #options
Instance Method Summary collapse
- #auth_hash ⇒ Object
- #callback_phase ⇒ Object
-
#initialize(app, client_id = nil, client_secret = nil, options = {}, &block) ⇒ Doit
constructor
A new instance of Doit.
- #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) ⇒ Doit
7 8 9 10 11 12 13 |
# File 'lib/omniauth/strategies/oauth2/doit.rb', line 7 def initialize(app, client_id=nil, client_secret=nil, ={}, &block) = { :authorize_url => 'https://openapi.doit.im/oauth/authorize', :token_url => 'https://openapi.doit.im/oauth/access_token', } super(app, :doit, client_id, client_secret, , , &block) end |
Instance Method Details
#auth_hash ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/omniauth/strategies/oauth2/doit.rb', line 15 def auth_hash OmniAuth::Utils.deep_merge( super, { 'uid' => user_data['id'], 'user_info' => user_info, 'extra' => { 'user_hash' => user_data, }, } ) end |
#callback_phase ⇒ Object
36 37 38 39 |
# File 'lib/omniauth/strategies/oauth2/doit.rb', line 36 def callback_phase [:grant_type] ||= 'authorization_code' super end |
#request_phase ⇒ Object
31 32 33 34 |
# File 'lib/omniauth/strategies/oauth2/doit.rb', line 31 def request_phase [:response_type] ||= 'code' super end |
#user_data ⇒ Object
27 28 29 |
# File 'lib/omniauth/strategies/oauth2/doit.rb', line 27 def user_data @data ||= MultiJson.decode(@access_token.get('https://openapi.doit.im/v1/settings'), {'Authorization' => 'OAuth' + @access_token.token}) end |
#user_info ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/omniauth/strategies/oauth2/doit.rb', line 41 def user_info { 'account' => user_data['account'], 'username'=> user_data['username'], 'nickname'=> user_data['nickname'], 'gender'=> user_data['gender'], 'week_start'=> user_data['week_start'], 'birthday_day'=> user_data['birthday_day'], 'birthday_month'=> user_data['birthday_month'], 'birthday_year'=> user_data['birthday_year'], 'language'=> user_data['language'], 'user_timezone'=> user_data['user_timezone'], 'remind_email'=> user_data['remind_email'], 'created'=> user_data['created'], 'updated'=> user_data['updated'], } end |