def _ExtractOAuth2Client(product_yaml_key, product_data, proxy_config):
 if all(((config in product_data) for config in _OAUTH2_INSTALLED_APP_KEYS)):
  oauth2_args = [product_data['client_id'], product_data['client_secret'], product_data['refresh_token']]
  oauth2_client = googleads.oauth2.GoogleRefreshTokenClient
  for key in _OAUTH2_INSTALLED_APP_KEYS:
   del product_data[key]
 elif all(((config in product_data) for config in _OAUTH2_SERVICE_ACCT_KEYS)):
  oauth2_args = [googleads.oauth2.GetAPIScope(product_yaml_key), product_data['service_account_email'], product_data['path_to_private_key_file']]
  oauth2_client = googleads.oauth2.GoogleServiceAccountClient
  for key in _OAUTH2_SERVICE_ACCT_KEYS:
   del product_data[key]
 else:
  raise googleads.errors.GoogleAdsValueError(('Your yaml file is incorrectly configured for OAuth2. You need to specify credentials for either the installed application flow (%s) or service account flow (%s).' % (_OAUTH2_INSTALLED_APP_KEYS, _OAUTH2_SERVICE_ACCT_KEYS)))
 return oauth2_client(proxy_config=proxy_config, *oauth2_args)

def _ExtractOAuth2Client ( product_yaml_key , product_data , proxy_config ) : if all ( ( ( config in product_data ) for config in _OAUTH2_INSTALLED_APP_KEYS ) ) : oauth2_args = [ product_data [ 'client_id' ] , product_data [ 'client_secret' ] , product_data [ 'refresh_token' ] ] oauth2_client = googleads . oauth2 . GoogleRefreshTokenClient for key in _OAUTH2_INSTALLED_APP_KEYS : del product_data [ key ] elif all ( ( ( config in product_data ) for config in _OAUTH2_SERVICE_ACCT_KEYS ) ) : oauth2_args = [ googleads . oauth2 . GetAPIScope ( product_yaml_key ) , product_data [ 'service_account_email' ] , product_data [ 'path_to_private_key_file' ] ] oauth2_client = googleads . oauth2 . GoogleServiceAccountClient for key in _OAUTH2_SERVICE_ACCT_KEYS : del product_data [ key ] else : raise googleads . errors . GoogleAdsValueError ( ( 'Your yaml file is incorrectly configured for OAuth2. You need to specify credentials for either the installed application flow (%s) or service account flow (%s).' % ( _OAUTH2_INSTALLED_APP_KEYS , _OAUTH2_SERVICE_ACCT_KEYS ) ) ) return oauth2_client ( proxy_config = proxy_config , * oauth2_args )
generates an googleoauth2client subclass using the given product_data .