本文整理匯總了Python中oauth2client.client.GoogleCredentials._get_implicit_credentials方法的典型用法代碼示例。如果您正苦於以下問題:Python GoogleCredentials._get_implicit_credentials方法的具體用法?Python GoogleCredentials._get_implicit_credentials怎麽用?Python GoogleCredentials._get_implicit_credentials使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類oauth2client.client.GoogleCredentials
的用法示例。
在下文中一共展示了GoogleCredentials._get_implicit_credentials方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _get_implicit_credentials
# 需要導入模塊: from oauth2client.client import GoogleCredentials [as 別名]
# 或者: from oauth2client.client.GoogleCredentials import _get_implicit_credentials [as 別名]
def _get_implicit_credentials(cls):
"""Gets credentials implicitly from the environment.
Checks environment in order of precedence:
- Google App Engine (production and testing)
- Environment variable GOOGLE_APPLICATION_CREDENTIALS pointing to
a file with stored credentials information.
- Stored "well known" file associated with `gcloud` command line tool.
- Google Compute Engine production environment.
Raises:
ApplicationDefaultCredentialsError: raised when the credentials
fail to be retrieved.
"""
# Environ checks (in order).
environ_checkers = [
cls._implicit_credentials_from_gae,
cls._implicit_credentials_from_files,
cls._implicit_credentials_from_gce,
]
for checker in environ_checkers:
credentials = checker()
if credentials is not None:
return credentials
# If no credentials, fail.
raise ApplicationDefaultCredentialsError(ADC_HELP_MSG)
示例2: get_application_default
# 需要導入模塊: from oauth2client.client import GoogleCredentials [as 別名]
# 或者: from oauth2client.client.GoogleCredentials import _get_implicit_credentials [as 別名]
def get_application_default():
"""Get the Application Default Credentials for the current environment.
Raises:
ApplicationDefaultCredentialsError: raised when the credentials
fail to be retrieved.
"""
return GoogleCredentials._get_implicit_credentials()
示例3: _get_implicit_credentials
# 需要導入模塊: from oauth2client.client import GoogleCredentials [as 別名]
# 或者: from oauth2client.client.GoogleCredentials import _get_implicit_credentials [as 別名]
def _get_implicit_credentials(cls):
"""Gets credentials implicitly from the environment.
Checks environment in order of precedence:
- Environment variable GOOGLE_APPLICATION_CREDENTIALS pointing to
a file with stored credentials information.
- Stored "well known" file associated with `gcloud` command line tool.
- Google App Engine (production and testing)
- Google Compute Engine production environment.
Raises:
ApplicationDefaultCredentialsError: raised when the credentials
fail to be retrieved.
"""
# Environ checks (in order).
environ_checkers = [
cls._implicit_credentials_from_files,
cls._implicit_credentials_from_gae,
cls._implicit_credentials_from_gce,
]
for checker in environ_checkers:
credentials = checker()
if credentials is not None:
return credentials
# If no credentials, fail.
raise ApplicationDefaultCredentialsError(ADC_HELP_MSG)