当前位置: 首页>>代码示例>>Python>>正文


Python exceptions.GoogleAuthError方法代码示例

本文整理汇总了Python中google.auth.exceptions.GoogleAuthError方法的典型用法代码示例。如果您正苦于以下问题:Python exceptions.GoogleAuthError方法的具体用法?Python exceptions.GoogleAuthError怎么用?Python exceptions.GoogleAuthError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在google.auth.exceptions的用法示例。


在下文中一共展示了exceptions.GoogleAuthError方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from google.auth import exceptions [as 别名]
# 或者: from google.auth.exceptions import GoogleAuthError [as 别名]
def __init__(self, target_credentials, target_audience=None, include_email=False):
        """
        Args:
            target_credentials (google.auth.Credentials): The target
                credential used as to acquire the id tokens for.
            target_audience (string): Audience to issue the token for.
            include_email (bool): Include email in IdToken
        """
        super(IDTokenCredentials, self).__init__()

        if not isinstance(target_credentials, Credentials):
            raise exceptions.GoogleAuthError(
                "Provided Credential must be " "impersonated_credentials"
            )
        self._target_credentials = target_credentials
        self._target_audience = target_audience
        self._include_email = include_email 
开发者ID:googleapis,项目名称:google-auth-library-python,代码行数:19,代码来源:impersonated_credentials.py

示例2: __init__

# 需要导入模块: from google.auth import exceptions [as 别名]
# 或者: from google.auth.exceptions import GoogleAuthError [as 别名]
def __init__(self, target_credentials,
                 target_audience=None, include_email=False):
        """
        Args:
            target_credentials (google.auth.Credentials): The target
                credential used as to acquire the id tokens for.
            target_audience (string): Audience to issue the token for.
            include_email (bool): Include email in IdToken
        """
        super(IDTokenCredentials, self).__init__()

        if not isinstance(target_credentials,
                          Credentials):
            raise exceptions.GoogleAuthError("Provided Credential must be "
                                             "impersonated_credentials")
        self._target_credentials = target_credentials
        self._target_audience = target_audience
        self._include_email = include_email 
开发者ID:luci,项目名称:luci-py,代码行数:20,代码来源:impersonated_credentials.py

示例3: _get_service

# 需要导入模块: from google.auth import exceptions [as 别名]
# 或者: from google.auth.exceptions import GoogleAuthError [as 别名]
def _get_service(self):
        """
        Connects and authenticates with the Google Ads API using a service account
        """
        with NamedTemporaryFile("w", suffix=".json") as secrets_temp:
            self._get_config()
            self._update_config_with_secret(secrets_temp)
            try:
                client = GoogleAdsClient.load_from_dict(self.google_ads_config)
                return client.get_service("GoogleAdsService", version=self.api_version)
            except GoogleAuthError as e:
                self.log.error("Google Auth Error: %s", e)
                raise 
开发者ID:apache,项目名称:airflow,代码行数:15,代码来源:ads.py

示例4: _get_customer_service

# 需要导入模块: from google.auth import exceptions [as 别名]
# 或者: from google.auth.exceptions import GoogleAuthError [as 别名]
def _get_customer_service(self):
        """
        Connects and authenticates with the Google Ads API using a service account
        """
        with NamedTemporaryFile("w", suffix=".json") as secrets_temp:
            self._get_config()
            self._update_config_with_secret(secrets_temp)
            try:
                client = GoogleAdsClient.load_from_dict(self.google_ads_config)
                return client.get_service("CustomerService", version=self.api_version)
            except GoogleAuthError as e:
                self.log.error("Google Auth Error: %s", e)
                raise 
开发者ID:apache,项目名称:airflow,代码行数:15,代码来源:ads.py

示例5: test_id_token_invalid_cred

# 需要导入模块: from google.auth import exceptions [as 别名]
# 或者: from google.auth.exceptions import GoogleAuthError [as 别名]
def test_id_token_invalid_cred(
        self, mock_donor_credentials, mock_authorizedsession_idtoken
    ):
        credentials = None

        with pytest.raises(exceptions.GoogleAuthError) as excinfo:
            impersonated_credentials.IDTokenCredentials(credentials)

        assert excinfo.match("Provided Credential must be" " impersonated_credentials") 
开发者ID:googleapis,项目名称:google-auth-library-python,代码行数:11,代码来源:test_impersonated_credentials.py

示例6: test_verify_oauth2_token_invalid_iss

# 需要导入模块: from google.auth import exceptions [as 别名]
# 或者: from google.auth.exceptions import GoogleAuthError [as 别名]
def test_verify_oauth2_token_invalid_iss(verify_token):
    verify_token.return_value = {"iss": "invalid_issuer"}

    with pytest.raises(exceptions.GoogleAuthError):
        id_token.verify_oauth2_token(
            mock.sentinel.token, mock.sentinel.request, audience=mock.sentinel.audience
        ) 
开发者ID:googleapis,项目名称:google-auth-library-python,代码行数:9,代码来源:test_id_token.py

示例7: verify_oauth2_token

# 需要导入模块: from google.auth import exceptions [as 别名]
# 或者: from google.auth.exceptions import GoogleAuthError [as 别名]
def verify_oauth2_token(id_token, request, audience=None):
    """Verifies an ID Token issued by Google's OAuth 2.0 authorization server.

    Args:
        id_token (Union[str, bytes]): The encoded token.
        request (google.auth.transport.Request): The object used to make
            HTTP requests.
        audience (str): The audience that this token is intended for. This is
            typically your application's OAuth 2.0 client ID. If None then the
            audience is not verified.

    Returns:
        Mapping[str, Any]: The decoded token.

    Raises:
        exceptions.GoogleAuthError: If the issuer is invalid.
    """
    idinfo = verify_token(
        id_token, request, audience=audience, certs_url=_GOOGLE_OAUTH2_CERTS_URL
    )

    if idinfo["iss"] not in _GOOGLE_ISSUERS:
        raise exceptions.GoogleAuthError(
            "Wrong issuer. 'iss' should be one of the following: {}".format(
                _GOOGLE_ISSUERS
            )
        )

    return idinfo 
开发者ID:googleapis,项目名称:google-auth-library-python,代码行数:31,代码来源:id_token.py

示例8: _fetch_table

# 需要导入模块: from google.auth import exceptions [as 别名]
# 或者: from google.auth.exceptions import GoogleAuthError [as 别名]
def _fetch_table(table_name):
    try:
        client = datastore.Client()
    except GoogleAuthError:
        # TODO(lcaggioni.ludomagno): fail gracefully
        pass
    return client.get(client.key('Table', table_name)) 
开发者ID:GoogleCloudPlatform,项目名称:professional-services,代码行数:9,代码来源:data_ingestion_configurable.py

示例9: validate_credentials

# 需要导入模块: from google.auth import exceptions [as 别名]
# 或者: from google.auth.exceptions import GoogleAuthError [as 别名]
def validate_credentials(self) -> None:
        try:
            for _ in self.client.list_buckets():
                break
        except GoogleAuthError as err:
            raise CredentialsError(str(err)) 
开发者ID:scottwernervt,项目名称:cloudstorage,代码行数:8,代码来源:google.py


注:本文中的google.auth.exceptions.GoogleAuthError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。