Skip to content

Minor fixes to changes due to wx feedback #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/planet_auth/oidc/request_authenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from typing import Dict, Optional

import planet_auth.logging.auth_logger
from planet_auth import AuthException
from planet_auth.credential import Credential
from planet_auth.request_authenticator import CredentialRequestAuthenticator
from planet_auth.oidc.auth_client import OidcAuthClient
Expand Down Expand Up @@ -123,6 +124,11 @@ def _refresh_if_needed(self):
msg="Error refreshing auth token. Continuing with old auth token. Refresh error: " + str(e)
)

if not (self._credential and self._credential.is_loaded()):
# "refresh" may also be called to initialize in some cases, as in client credentials flow.
# Continuing with what we have is not an option when we have nothing.
raise AuthException("Failed to load or obtain a valid access token.")

def pre_request_hook(self):
self._refresh_if_needed()
super().pre_request_hook()
Expand Down
8 changes: 6 additions & 2 deletions src/planet_auth_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@
from .commands.cli.util import recast_exceptions_to_click
from planet_auth_utils.constants import EnvironmentVariables
from planet_auth_utils.plauth_factory import PlanetAuthFactory
from planet_auth_utils.builtins import Builtins, BuiltinConfigurationProviderInterface
from planet_auth_utils.builtins import (
Builtins,
# Easily causes circular dependencies. Intentionally not part of the main package interface for now.
# BuiltinConfigurationProviderInterface,
)
from planet_auth_utils.profile import Profile
from planet_auth_utils.plauth_user_config import PlanetAuthUserConfig

Expand Down Expand Up @@ -161,7 +165,7 @@
"recast_exceptions_to_click",
#
"Builtins",
"BuiltinConfigurationProviderInterface",
# "BuiltinConfigurationProviderInterface",
"EnvironmentVariables",
"PlanetAuthFactory",
"Profile",
Expand Down