Skip to content

Commit

Permalink
Add whoami
Browse files Browse the repository at this point in the history
  • Loading branch information
danielballan committed Jan 9, 2025
1 parent a5ae676 commit b3f948e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tiled/commandline/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit b3f948e

Please sign in to comment.