Skip to content

Commit

Permalink
made session Manager return None from config
Browse files Browse the repository at this point in the history
  • Loading branch information
ZohebShaikh committed Oct 17, 2024
1 parent 1326164 commit 79cdff9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/blueapi/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class OAuthClientConfig(BlueapiBaseModel):


class CLIClientConfig(OAuthClientConfig):
token_file_path: Path | None = Path("~/token")
token_file_path: Path = Path("~/token")


class ApplicationConfig(BlueapiBaseModel):
Expand All @@ -146,7 +146,7 @@ class ApplicationConfig(BlueapiBaseModel):
api: RestConfig = Field(default_factory=RestConfig)
scratch: ScratchConfig | None = None
oauth_server: OAuthServerConfig | None = None
oauth_client: CLIClientConfig | None = None
oauth_client: OAuthClientConfig | CLIClientConfig | None = None

def __eq__(self, other: object) -> bool:
if isinstance(other, ApplicationConfig):
Expand Down
7 changes: 4 additions & 3 deletions src/blueapi/service/authentication.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import base64
import json
import os
Expand Down Expand Up @@ -109,15 +111,14 @@ def from_config(
cls,
server_config: OAuthServerConfig | None,
client_config: OAuthClientConfig | None,
) -> "SessionManager":
) -> SessionManager | None:
if server_config and client_config:
if isinstance(client_config, CLIClientConfig):
return SessionManager(
server_config,
client_config,
CLITokenManager(Path(client_config.token_file_path)), # type: ignore
CLITokenManager(Path(client_config.token_file_path)),
)
# raise NotImplementedError("Only CLI client config is supported")

def get_token(self) -> dict[str, Any] | None:
return self._token_manager.load_token()
Expand Down

0 comments on commit 79cdff9

Please sign in to comment.