diff --git a/google/cloud/privatecatalog_v1beta1/services/private_catalog/transports/base.py b/google/cloud/privatecatalog_v1beta1/services/private_catalog/transports/base.py index 3f78512..53d47b3 100644 --- a/google/cloud/privatecatalog_v1beta1/services/private_catalog/transports/base.py +++ b/google/cloud/privatecatalog_v1beta1/services/private_catalog/transports/base.py @@ -98,7 +98,7 @@ def __init__( scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) # Save the scopes. - self._scopes = scopes or self.AUTH_SCOPES + self._scopes = scopes # If no credentials are provided, then determine the appropriate # defaults. diff --git a/google/cloud/privatecatalog_v1beta1/services/private_catalog/transports/grpc.py b/google/cloud/privatecatalog_v1beta1/services/private_catalog/transports/grpc.py index 2d96aa0..9dde445 100644 --- a/google/cloud/privatecatalog_v1beta1/services/private_catalog/transports/grpc.py +++ b/google/cloud/privatecatalog_v1beta1/services/private_catalog/transports/grpc.py @@ -78,6 +78,7 @@ def __init__( client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, ) -> None: """Instantiate the transport. @@ -118,6 +119,8 @@ def __init__( API requests. If ``None``, then default info will be used. Generally, you only need to set this if you're developing your own client library. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. Raises: google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport @@ -170,7 +173,7 @@ def __init__( scopes=scopes, quota_project_id=quota_project_id, client_info=client_info, - always_use_jwt_access=True, + always_use_jwt_access=always_use_jwt_access, ) if not self._grpc_channel: diff --git a/google/cloud/privatecatalog_v1beta1/services/private_catalog/transports/grpc_asyncio.py b/google/cloud/privatecatalog_v1beta1/services/private_catalog/transports/grpc_asyncio.py index 868a5ff..bf66254 100644 --- a/google/cloud/privatecatalog_v1beta1/services/private_catalog/transports/grpc_asyncio.py +++ b/google/cloud/privatecatalog_v1beta1/services/private_catalog/transports/grpc_asyncio.py @@ -124,6 +124,7 @@ def __init__( client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, quota_project_id=None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, ) -> None: """Instantiate the transport. @@ -165,6 +166,8 @@ def __init__( API requests. If ``None``, then default info will be used. Generally, you only need to set this if you're developing your own client library. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. Raises: google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport @@ -216,7 +219,7 @@ def __init__( scopes=scopes, quota_project_id=quota_project_id, client_info=client_info, - always_use_jwt_access=True, + always_use_jwt_access=always_use_jwt_access, ) if not self._grpc_channel: diff --git a/tests/unit/gapic/privatecatalog_v1beta1/test_private_catalog.py b/tests/unit/gapic/privatecatalog_v1beta1/test_private_catalog.py index 6e3bbb3..4a07744 100644 --- a/tests/unit/gapic/privatecatalog_v1beta1/test_private_catalog.py +++ b/tests/unit/gapic/privatecatalog_v1beta1/test_private_catalog.py @@ -131,7 +131,25 @@ def test_private_catalog_client_service_account_always_use_jwt(client_class): ) as use_jwt: creds = service_account.Credentials(None, None, None) client = client_class(credentials=creds) - use_jwt.assert_called_with(True) + use_jwt.assert_not_called() + + +@pytest.mark.parametrize( + "transport_class,transport_name", + [ + (transports.PrivateCatalogGrpcTransport, "grpc"), + (transports.PrivateCatalogGrpcAsyncIOTransport, "grpc_asyncio"), + ], +) +def test_private_catalog_client_service_account_always_use_jwt_true( + transport_class, transport_name +): + with mock.patch.object( + service_account.Credentials, "with_always_use_jwt_access", create=True + ) as use_jwt: + creds = service_account.Credentials(None, None, None) + transport = transport_class(credentials=creds, always_use_jwt_access=True) + use_jwt.assert_called_once_with(True) @pytest.mark.parametrize( @@ -1584,7 +1602,7 @@ def test_private_catalog_grpc_transport_client_cert_source_for_mtls(transport_cl "squid.clam.whelk:443", credentials=cred, credentials_file=None, - scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=None, ssl_credentials=mock_ssl_channel_creds, quota_project_id=None, options=[ @@ -1693,7 +1711,7 @@ def test_private_catalog_transport_channel_mtls_with_client_cert_source( "mtls.squid.clam.whelk:443", credentials=cred, credentials_file=None, - scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=None, ssl_credentials=mock_ssl_cred, quota_project_id=None, options=[ @@ -1740,7 +1758,7 @@ def test_private_catalog_transport_channel_mtls_with_adc(transport_class): "mtls.squid.clam.whelk:443", credentials=mock_cred, credentials_file=None, - scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=None, ssl_credentials=mock_ssl_cred, quota_project_id=None, options=[