|
22 | 22 | import google.auth.credentials |
23 | 23 | import requests.adapters |
24 | 24 |
|
25 | | -import bigframes._config.auth |
26 | 25 | import bigframes._importing |
27 | 26 | import bigframes.enums |
28 | 27 | import bigframes.exceptions as bfe |
|
38 | 37 |
|
39 | 38 | def _get_validated_location(value: Optional[str]) -> Optional[str]: |
40 | 39 | import bigframes._tools.strings |
41 | | - import bigframes.constants |
42 | 40 |
|
43 | 41 | if value is None or value in bigframes.constants.ALL_BIGQUERY_LOCATIONS: |
44 | 42 | return value |
@@ -143,52 +141,20 @@ def application_name(self, value: Optional[str]): |
143 | 141 | ) |
144 | 142 | self._application_name = value |
145 | 143 |
|
146 | | - def _try_set_default_credentials_and_project( |
147 | | - self, |
148 | | - ) -> tuple[google.auth.credentials.Credentials, Optional[str]]: |
149 | | - # Don't fetch credentials or project if credentials is already set. |
150 | | - # If it's set, we've already authenticated, so if the user wants to |
151 | | - # re-auth, they should explicitly reset the credentials. |
152 | | - if self._credentials is not None: |
153 | | - return self._credentials, self._project |
154 | | - |
155 | | - ( |
156 | | - credentials, |
157 | | - credentials_project, |
158 | | - ) = bigframes._config.auth.get_default_credentials_with_project() |
159 | | - self._credentials = credentials |
160 | | - |
161 | | - # Avoid overriding an explicitly set project with a default value. |
162 | | - if self._project is None: |
163 | | - self._project = credentials_project |
164 | | - |
165 | | - return credentials, self._project |
166 | | - |
167 | 144 | @property |
168 | | - def credentials(self) -> google.auth.credentials.Credentials: |
| 145 | + def credentials(self) -> Optional[google.auth.credentials.Credentials]: |
169 | 146 | """The OAuth2 credentials to use for this client. |
170 | 147 |
|
171 | | - Set to None to force re-authentication. |
172 | | -
|
173 | 148 | Returns: |
174 | 149 | None or google.auth.credentials.Credentials: |
175 | 150 | google.auth.credentials.Credentials if exists; otherwise None. |
176 | 151 | """ |
177 | | - if self._credentials: |
178 | | - return self._credentials |
179 | | - |
180 | | - credentials, _ = self._try_set_default_credentials_and_project() |
181 | | - return credentials |
| 152 | + return self._credentials |
182 | 153 |
|
183 | 154 | @credentials.setter |
184 | 155 | def credentials(self, value: Optional[google.auth.credentials.Credentials]): |
185 | 156 | if self._session_started and self._credentials is not value: |
186 | 157 | raise ValueError(SESSION_STARTED_MESSAGE.format(attribute="credentials")) |
187 | | - |
188 | | - if value is None: |
189 | | - # The user has _explicitly_ asked that we re-authenticate. |
190 | | - bigframes._config.auth.reset_default_credentials_and_project() |
191 | | - |
192 | 158 | self._credentials = value |
193 | 159 |
|
194 | 160 | @property |
@@ -217,11 +183,7 @@ def project(self) -> Optional[str]: |
217 | 183 | None or str: |
218 | 184 | Google Cloud project ID as a string; otherwise None. |
219 | 185 | """ |
220 | | - if self._project: |
221 | | - return self._project |
222 | | - |
223 | | - _, project = self._try_set_default_credentials_and_project() |
224 | | - return project |
| 186 | + return self._project |
225 | 187 |
|
226 | 188 | @project.setter |
227 | 189 | def project(self, value: Optional[str]): |
|
0 commit comments