File tree 1 file changed +6
-0
lines changed
1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change 17
17
from typing import Dict , Optional
18
18
19
19
import planet_auth .logging .auth_logger
20
+ from planet_auth import AuthException
20
21
from planet_auth .credential import Credential
21
22
from planet_auth .request_authenticator import CredentialRequestAuthenticator
22
23
from planet_auth .oidc .auth_client import OidcAuthClient
@@ -123,6 +124,11 @@ def _refresh_if_needed(self):
123
124
msg = "Error refreshing auth token. Continuing with old auth token. Refresh error: " + str (e )
124
125
)
125
126
127
+ if not (self ._credential and self ._credential .is_loaded ()):
128
+ # "refresh" may also be called to initialize in some cases, as in client credentials flow.
129
+ # Continuing with what we have is not an option when we have nothing.
130
+ raise AuthException ("Failed to load or obtain a valid access token." )
131
+
126
132
def pre_request_hook (self ):
127
133
self ._refresh_if_needed ()
128
134
super ().pre_request_hook ()
You can’t perform that action at this time.
0 commit comments