Skip to content

Commit b236ace

Browse files
pull out new error. It causes downstream errors, and was only added in an attempt to give better errors, not change behavior.
1 parent 5dee276 commit b236ace

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/planet_auth/oidc/request_authenticator.py

+14-10
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from typing import Dict, Optional
1818

1919
import planet_auth.logging.auth_logger
20-
from planet_auth import AuthException
2120
from planet_auth.credential import Credential
2221
from planet_auth.request_authenticator import CredentialRequestAuthenticator
2322
from planet_auth.oidc.auth_client import OidcAuthClient
@@ -114,23 +113,28 @@ def _refresh_if_needed(self):
114113
self._load()
115114
except Exception as e: # pylint: disable=broad-exception-caught
116115
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)}"
118117
)
119118
if now > self._refresh_at:
120119
try:
121120
self._refresh()
122121
except Exception as e: # pylint: disable=broad-exception-caught
123122
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)}"
125124
)
126125

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.")
134138

135139
def pre_request_hook(self):
136140
self._refresh_if_needed()

0 commit comments

Comments
 (0)