def _get_gcp_credentials(module, require_valid_json=True, check_libcloud=False):
 (service_account_email, credentials_file, project_id) = _get_gcp_ansible_credentials(module)
 (service_account_email, credentials_file, project_id) = _get_gcp_environment_credentials(service_account_email, credentials_file, project_id)
 (service_account_email, credentials_file, project_id) = _get_gcp_libcloud_credentials(service_account_email, credentials_file, project_id)
 if ((credentials_file is None) or (project_id is None) or (service_account_email is None)):
  if (check_libcloud is True):
   module.fail_json(msg='Missing GCE connection parameters in libcloud secrets file.')
   return None
  elif ((credentials_file is None) or (project_id is None)):
   module.fail_json(msg=('GCP connection error: enable to determine project (%s) orcredentials file (%s)' % (project_id, credentials_file)))
 _validate_credentials_file(module, credentials_file, require_valid_json=require_valid_json, check_libcloud=check_libcloud)
 return {'service_account_email': service_account_email, 'credentials_file': credentials_file, 'project_id': project_id}

def _get_gcp_credentials ( module , require_valid_json = True , check_libcloud = False ) : ( service_account_email , credentials_file , project_id ) = _get_gcp_ansible_credentials ( module ) ( service_account_email , credentials_file , project_id ) = _get_gcp_environment_credentials ( service_account_email , credentials_file , project_id ) ( service_account_email , credentials_file , project_id ) = _get_gcp_libcloud_credentials ( service_account_email , credentials_file , project_id ) if ( ( credentials_file is None ) or ( project_id is None ) or ( service_account_email is None ) ) : if ( check_libcloud is True ) : module . fail_json ( msg = 'Missing GCE connection parameters in libcloud secrets file.' ) return None elif ( ( credentials_file is None ) or ( project_id is None ) ) : module . fail_json ( msg = ( 'GCP connection error: enable to determine project (%s) orcredentials file (%s)' % ( project_id , credentials_file ) ) ) _validate_credentials_file ( module , credentials_file , require_valid_json = require_valid_json , check_libcloud = check_libcloud ) return { 'service_account_email' : service_account_email , 'credentials_file' : credentials_file , 'project_id' : project_id }
obtain gcp credentials by trying various methods .