Skip to content

Commit

Permalink
Handle optionality of API key setting correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielballan committed Jan 8, 2025
1 parent 4b01e80 commit 274e97e
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions tiled/client/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,14 +434,18 @@ def from_app(
app=app,
raise_server_exceptions=raise_server_exceptions,
)
if (api_key is UNSET) and (
not context.server_info["authentication"]["providers"]
):
# Extract the API key from the app and set it.
from ..server.settings import get_settings

settings = app.dependency_overrides[get_settings]()
api_key = settings.single_user_api_key or None
if api_key is UNSET:
if not context.server_info["authentication"]["providers"]:
# This is a single-user server.
# Extract the API key from the app and set it.
from ..server.settings import get_settings

settings = app.dependency_overrides[get_settings]()
api_key = settings.single_user_api_key or None
else:
# This is a multi-user server but no API key was passed,
# so we will leave it as None on the Context.
api_key = None
context.api_key = api_key
return context

Expand Down

0 comments on commit 274e97e

Please sign in to comment.