@@ -67,7 +67,7 @@ class {{ service.name }}Transport(abc.ABC):
6767 scopes: Optional[Sequence[str]] = None,
6868 quota_project_id: Optional[str] = None,
6969 client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
70- **kwargs,
70+ **kwargs,
7171 ) -> None:
7272 """Instantiate the transport.
7373
@@ -85,10 +85,10 @@ class {{ service.name }}Transport(abc.ABC):
8585 scopes (Optional[Sequence[str]]): A list of scopes.
8686 quota_project_id (Optional[str]): An optional project to use for billing
8787 and quota.
88- client_info (google.api_core.gapic_v1.client_info.ClientInfo):
89- The client info used to send a user-agent string along with
90- API requests. If ``None``, then default info will be used.
91- Generally, you only need to set this if you're developing
88+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
89+ The client info used to send a user-agent string along with
90+ API requests. If ``None``, then default info will be used.
91+ Generally, you only need to set this if you're developing
9292 your own client library.
9393 """
9494 # Save the hostname. Default to port 443 (HTTPS) if none is specified.
@@ -99,13 +99,13 @@ class {{ service.name }}Transport(abc.ABC):
9999 scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
100100
101101 # Save the scopes.
102- self._scopes = scopes_kwargs[" scopes"]
102+ self._scopes = scopes or self.AUTH_SCOPES
103103
104104 # If no credentials are provided, then determine the appropriate
105105 # defaults.
106106 if credentials and credentials_file:
107107 raise exceptions.DuplicateCredentialArgs("'credentials_file' and 'credentials' are mutually exclusive")
108-
108+
109109 if credentials_file is not None:
110110 credentials, _ = auth.load_credentials_from_file(
111111 credentials_file,
@@ -120,19 +120,7 @@ class {{ service.name }}Transport(abc.ABC):
120120 self._credentials = credentials
121121
122122
123- @classmethod
124- def _get_user_scopes(cls, host: str, scopes: Optional[Sequence[str]]) -> Optional[Sequence[str]]:
125- if scopes is None:
126- # If a custom API endpoint is set, set user scopes to ensure the auth
127- # library does not used the self-signed JWT flow for service
128- # accounts.
129- if host.split(":")[0] != cls.DEFAULT_HOST.split(":")[0]:
130- scopes = cls.AUTH_SCOPES
131-
132- return scopes
133-
134-
135- # TODO(busunkim): These two class methods are in the base transport
123+ # TODO(busunkim): These two class methods are in the base transport
136124 # to avoid duplicating code across the transport classes. These functions
137125 # should be deleted once the minimum required versions of google-api-core
138126 # and google-auth are increased.
@@ -142,7 +130,6 @@ class {{ service.name }}Transport(abc.ABC):
142130 def _get_scopes_kwargs(cls, host: str, scopes: Optional[Sequence[str]]) -> Dict[str, Optional[Sequence[str]]]:
143131 """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version"""
144132
145- scopes = cls._get_user_scopes(host, scopes)
146133 scopes_kwargs = {}
147134
148135 if _GOOGLE_AUTH_VERSION and (
@@ -152,17 +139,16 @@ class {{ service.name }}Transport(abc.ABC):
152139 scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES}
153140 else:
154141 scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES}
155-
142+
156143 return scopes_kwargs
157144
158145 # TODO: Remove this function once google-api-core >= 1.26.0 is required
159146 @classmethod
160147 def _get_self_signed_jwt_kwargs(cls, host: str, scopes: Optional[Sequence[str]]) -> Dict[str, Union[Optional[Sequence[str]], str]]:
161148 """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version"""
162- scopes = cls._get_user_scopes(host, scopes)
163149
164150 self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {}
165-
151+
166152 if _API_CORE_VERSION and (
167153 packaging.version.parse(_API_CORE_VERSION)
168154 >= packaging.version.parse("1.26.0")
@@ -172,7 +158,7 @@ class {{ service.name }}Transport(abc.ABC):
172158 self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST
173159 else:
174160 self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES
175-
161+
176162 return self_signed_jwt_kwargs
177163
178164
@@ -251,7 +237,7 @@ class {{ service.name }}Transport(abc.ABC):
251237 ],
252238 ]:
253239 raise NotImplementedError()
254- {% endif %}
240+ {% endif %}
255241
256242__all__ = (
257243 '{{ service.name }}Transport',
0 commit comments