|
15 | 15 | #
|
16 | 16 | import abc
|
17 | 17 | from typing import Awaitable, Callable, Dict, Optional, Sequence, Union
|
18 |
| -import packaging.version |
19 | 18 | import pkg_resources
|
20 | 19 |
|
21 | 20 | import google.auth # type: ignore
|
|
37 | 36 | except pkg_resources.DistributionNotFound:
|
38 | 37 | DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
|
39 | 38 |
|
40 |
| -try: |
41 |
| - # google.auth.__version__ was added in 1.26.0 |
42 |
| - _GOOGLE_AUTH_VERSION = google.auth.__version__ |
43 |
| -except AttributeError: |
44 |
| - try: # try pkg_resources if it is available |
45 |
| - _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version |
46 |
| - except pkg_resources.DistributionNotFound: # pragma: NO COVER |
47 |
| - _GOOGLE_AUTH_VERSION = None |
48 |
| - |
49 | 39 |
|
50 | 40 | class ConnectionServiceTransport(abc.ABC):
|
51 | 41 | """Abstract transport class for ConnectionService."""
|
@@ -95,7 +85,7 @@ def __init__(
|
95 | 85 | host += ":443"
|
96 | 86 | self._host = host
|
97 | 87 |
|
98 |
| - scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) |
| 88 | + scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} |
99 | 89 |
|
100 | 90 | # Save the scopes.
|
101 | 91 | self._scopes = scopes
|
@@ -128,29 +118,6 @@ def __init__(
|
128 | 118 | # Save the credentials.
|
129 | 119 | self._credentials = credentials
|
130 | 120 |
|
131 |
| - # TODO(busunkim): This method is in the base transport |
132 |
| - # to avoid duplicating code across the transport classes. These functions |
133 |
| - # should be deleted once the minimum required versions of google-auth is increased. |
134 |
| - |
135 |
| - # TODO: Remove this function once google-auth >= 1.25.0 is required |
136 |
| - @classmethod |
137 |
| - def _get_scopes_kwargs( |
138 |
| - cls, host: str, scopes: Optional[Sequence[str]] |
139 |
| - ) -> Dict[str, Optional[Sequence[str]]]: |
140 |
| - """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" |
141 |
| - |
142 |
| - scopes_kwargs = {} |
143 |
| - |
144 |
| - if _GOOGLE_AUTH_VERSION and ( |
145 |
| - packaging.version.parse(_GOOGLE_AUTH_VERSION) |
146 |
| - >= packaging.version.parse("1.25.0") |
147 |
| - ): |
148 |
| - scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} |
149 |
| - else: |
150 |
| - scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} |
151 |
| - |
152 |
| - return scopes_kwargs |
153 |
| - |
154 | 121 | def _prep_wrapped_messages(self, client_info):
|
155 | 122 | # Precompute the wrapped methods.
|
156 | 123 | self._wrapped_methods = {
|
|
0 commit comments