Class: AdsCommon::Auth::ClientLoginHandler
- Inherits:
-
BaseHandler
- Object
- BaseHandler
- AdsCommon::Auth::ClientLoginHandler
- Defined in:
- lib/ads_common/auth/client_login_handler.rb
Overview
Credentials class to handle ClientLogin authentication.
Constant Summary collapse
- ACCOUNT_TYPE =
'GOOGLE'
- AUTH_PATH =
'/accounts/ClientLogin'
- IGNORED_FIELDS =
[:email, :password, :auth_token]
Instance Method Summary collapse
-
#auth_string(credentials, request) ⇒ Object
Returns authorization string.
-
#handle_error(error) ⇒ Object
Handle specific ClientLogin errors.
-
#header_list(credentials) ⇒ Object
Returns all of the fields that this auth handler will fill.
-
#headers(credentials) ⇒ Object
Returns all of the credentials received from the CredentialHandler, except for ignored fields.
-
#initialize(config, server, service_name) ⇒ ClientLoginHandler
constructor
Initializes the ClientLoginHandler with all the necessary details.
-
#property_changed(prop, value) ⇒ Object
Invalidates the stored token if the email, password or provided auth token have changed.
Methods inherited from BaseHandler
Constructor Details
#initialize(config, server, service_name) ⇒ ClientLoginHandler
Initializes the ClientLoginHandler with all the necessary details.
39 40 41 42 43 |
# File 'lib/ads_common/auth/client_login_handler.rb', line 39 def initialize(config, server, service_name) super(config) @server = server @service_name = service_name end |
Instance Method Details
#auth_string(credentials, request) ⇒ Object
Returns authorization string.
80 81 82 |
# File 'lib/ads_common/auth/client_login_handler.rb', line 80 def auth_string(credentials, request) return ("GoogleLogin auth=%s" % get_token(credentials)) end |
#handle_error(error) ⇒ Object
Handle specific ClientLogin errors.
54 55 56 57 58 |
# File 'lib/ads_common/auth/client_login_handler.rb', line 54 def handle_error(error) # TODO: Add support for automatically regenerating auth tokens when they # expire. raise error end |
#header_list(credentials) ⇒ Object
Returns all of the fields that this auth handler will fill.
61 62 63 64 65 66 67 |
# File 'lib/ads_common/auth/client_login_handler.rb', line 61 def header_list(credentials) result = credentials.keys.map.reject do |field| IGNORED_FIELDS.include?(field) end result << :authToken return result end |
#headers(credentials) ⇒ Object
Returns all of the credentials received from the CredentialHandler, except for ignored fields.
71 72 73 74 75 76 77 |
# File 'lib/ads_common/auth/client_login_handler.rb', line 71 def headers(credentials) result = credentials.reject do |field, value| IGNORED_FIELDS.include?(field) end result[:authToken] = get_token(credentials) return result end |
#property_changed(prop, value) ⇒ Object
Invalidates the stored token if the email, password or provided auth token have changed.
47 48 49 50 51 |
# File 'lib/ads_common/auth/client_login_handler.rb', line 47 def property_changed(prop, value) if [:auth_token, :email, :password].include?(prop) @token = nil end end |