Class: AdsCommonForBingAds::Auth::ClientLoginHandler

Inherits:
AdsCommon::Auth::ClientLoginHandler
  • Object
show all
Defined in:
lib/ads_common_for_bing_ads.rb,
lib/ads_common_for_bing_ads/auth/client_login_handler.rb

Instance Method Summary collapse

Instance Method Details

#auth_string(credentials, request) ⇒ Object

Returns authorization string.



28
29
30
# File 'lib/ads_common_for_bing_ads/auth/client_login_handler.rb', line 28

def auth_string(credentials, request)
  return [AUTH_PREFIX, get_token(credentials)].join
end

#handle_error(error) ⇒ Object

Handle specific ClientLogin errors.



20
21
22
23
24
25
# File 'lib/ads_common_for_bing_ads/auth/client_login_handler.rb', line 20

def handle_error(error)
  # TODO: Add support for automatically regenerating auth tokens when they
  # expire.
  get_logger().error(error)
  raise error
end

#property_changed(prop, value) ⇒ Object

Invalidates the stored token if the user_name, password or provided auth token have changed.



10
11
12
13
14
15
16
17
# File 'lib/ads_common_for_bing_ads/auth/client_login_handler.rb', line 10

def property_changed(prop, value)
  if [:user_name, :password].include?(prop)
    @token = nil
  end
  if :auth_token.eql?(prop)
    @token = create_token_from_string(value)
  end
end