Class: OmniAuth::Strategies::WePay
- Defined in:
- lib/omniauth/strategies/oauth2/we_pay.rb
Overview
OAuth 2.0 based authentication with WePay. In order to sign up for an application, you need to register an application and provide the proper credentials to this middleware.
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) ⇒ WePay
constructor
A new instance of WePay.
- #user_data ⇒ Object
- #user_info ⇒ Object
Methods inherited from OAuth2
Constructor Details
#initialize(app, client_id = nil, client_secret = nil, options = {}, &block) ⇒ WePay
Returns a new instance of WePay.
13 14 15 16 17 18 19 |
# File 'lib/omniauth/strategies/oauth2/we_pay.rb', line 13 def initialize(app, client_id=nil, client_secret=nil, ={}, &block) = { :authorize_url => 'https://www.wepay.com/session/authorize', :token_url => 'https://wepayapi.com/v1/oauth2/token', } super(app, :we_pay, client_id, client_secret, , , &block) end |
Instance Method Details
#auth_hash ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/omniauth/strategies/oauth2/we_pay.rb', line 21 def auth_hash OmniAuth::Utils.deep_merge( super, { 'uid' => user_data['user_id'], 'user_info' => user_info, 'extra' => { 'user_hash' => user_data, }, } ) end |
#user_data ⇒ Object
33 34 35 |
# File 'lib/omniauth/strategies/oauth2/we_pay.rb', line 33 def user_data @data ||= MultiJson.decode(@access_token.get('/v1/user'))['result'] end |
#user_info ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/omniauth/strategies/oauth2/we_pay.rb', line 37 def user_info { 'email' => user_data['email'], 'name' => "#{user_data['firstName']} #{user_data['lastName']}".strip, 'first_name' => user_data['firstName'], 'last_name' => user_data['lastName'], 'image' => user_data['picture'], } end |