當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。