|
17 | 17 | from typing import Dict, Optional
|
18 | 18 |
|
19 | 19 | import planet_auth.logging.auth_logger
|
20 |
| -from planet_auth import AuthException |
21 | 20 | from planet_auth.credential import Credential
|
22 | 21 | from planet_auth.request_authenticator import CredentialRequestAuthenticator
|
23 | 22 | from planet_auth.oidc.auth_client import OidcAuthClient
|
@@ -114,23 +113,28 @@ def _refresh_if_needed(self):
|
114 | 113 | self._load()
|
115 | 114 | except Exception as e: # pylint: disable=broad-exception-caught
|
116 | 115 | auth_logger.warning(
|
117 |
| - msg="Error loading auth token. Continuing with old auth token. Load error: " + str(e) |
| 116 | + msg=f"Error loading auth token. Continuing with old configuration and token data. Load error: {str(e)}" |
118 | 117 | )
|
119 | 118 | if now > self._refresh_at:
|
120 | 119 | try:
|
121 | 120 | self._refresh()
|
122 | 121 | except Exception as e: # pylint: disable=broad-exception-caught
|
123 | 122 | auth_logger.warning(
|
124 |
| - msg="Error refreshing auth token. Continuing with old auth token. Refresh error: " + str(e) |
| 123 | + msg=f"Error obtaining new or refreshed auth token. Continuing with old configuration and token data. Refresh error: {str(e)}" |
125 | 124 | )
|
126 | 125 |
|
127 |
| - # FIXME? |
128 |
| - # Why is this breaking the SDK CICD? Why only for the pipeline and not a local nox? |
129 |
| - # The pipeline should be using a legacy API key, so why is this even being called? |
130 |
| - if not (self._credential and self._credential.is_loaded()): |
131 |
| - # "refresh" may also be called to initialize in some cases, as in client credentials flow. |
132 |
| - # Continuing with what we have is not an option when we have nothing. |
133 |
| - raise AuthException("Failed to load or obtain a valid access token.") |
| 126 | + # This tries to give a client a better error when there is no old |
| 127 | + # token to fall back to. But, it is known to cause problems when |
| 128 | + # auth truly isn't needed, either because the service does not need |
| 129 | + # it or because it has been mocked out (as in unit test cases). |
| 130 | + # So, we rely on the warnings to keep the user informed. This might |
| 131 | + # also result in the user seeing errors from the server - the quality |
| 132 | + # of which we have no control over. |
| 133 | + # |
| 134 | + # if not (self._credential and self._credential.is_loaded()): |
| 135 | + # # "refresh" may also be called to initialize in some cases, as in client credentials flow. |
| 136 | + # # Continuing with what we have is not an option when we have nothing. |
| 137 | + # raise AuthException("Failed to load or obtain a valid access token.") |
134 | 138 |
|
135 | 139 | def pre_request_hook(self):
|
136 | 140 | self._refresh_if_needed()
|
|
0 commit comments