Skip to content
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

Clean up Python client auth #836

Merged
merged 20 commits into from
Jan 9, 2025
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add whoami
  • Loading branch information
danielballan committed Jan 9, 2025
commit b3f948e5773860bdce75e098efd6115c62263ce7
22 changes: 22 additions & 0 deletions tiled/commandline/main.py
Original file line number Diff line number Diff line change
@@ -78,6 +78,28 @@ def login(
typer.echo(json.dumps(dict(context.tokens), indent=4))


@cli_app.command("whoami")
def whoami(
profile: Optional[str] = typer.Option(
None, help="If you use more than one Tiled server, use this to specify which."
),
):
"""
Show logged in identity.
"""
from ..client.context import Context

profile_name, profile_content = get_profile(profile)
options = {"verify": profile_content.get("verify", True)}
context, _ = Context.from_any_uri(profile_content["uri"], **options)
context.use_cached_tokens()
whoami = context.whoami()
if whoami is None:
typer.echo("Not authenticated.")
else:
typer.echo(",".join(identity["id"] for identity in whoami["identities"]))


@cli_app.command("logout")
def logout(
profile: Optional[str] = typer.Option(
Loading