|
13 | 13 | import aiohttp |
14 | 14 | import typer |
15 | 15 | from loguru import logger |
| 16 | +from rich.columns import Columns |
16 | 17 | from rich.live import Live |
17 | 18 | from rich.panel import Panel |
18 | 19 |
|
@@ -151,10 +152,7 @@ async def login(): |
151 | 152 | Panel( |
152 | 153 | "The web browser should have opened for you to authenticate with Pipecat Cloud.\n" |
153 | 154 | "If it didn't, please copy this URL into your web browser manually:\n\n" |
154 | | - f"[blue][link={web_url}]{web_url}[/link][/blue]\n", |
155 | | - ) |
156 | | - ) |
157 | | - ) |
| 155 | + f"[blue][link={web_url}]{web_url}[/link][/blue]\n", ))) |
158 | 156 | else: |
159 | 157 | # For headless use-cases, just print the URL |
160 | 158 | live.stop() |
@@ -222,7 +220,7 @@ async def logout(): |
222 | 220 | ) |
223 | 221 |
|
224 | 222 |
|
225 | | -@auth_cli.command(name="whoami", help="Display data about the current user.") |
| 223 | +@auth_cli.command(name="whoami", help="Display data about the current user. Also show Daily API key.") |
226 | 224 | @synchronizer.create_blocking |
227 | 225 | @requires_login |
228 | 226 | async def whomai(): |
@@ -251,11 +249,26 @@ async def whomai(): |
251 | 249 | if not account["name"] or not account["verbose_name"]: |
252 | 250 | raise |
253 | 251 |
|
254 | | - live.stop() |
| 252 | + # Retrieve user Daily API key |
| 253 | + # Note: we don't raise an error if this fails, as it's not required for |
| 254 | + # the CLI to function |
| 255 | + live.update(console.status("[dim]Fetching Daily API key...[/dim]", spinner="dots")) |
255 | 256 |
|
256 | | - console.success( |
257 | | - f"[bold]User ID:[/bold] {user_data['user']['userId']}\n" |
258 | | - f"[bold]Active Organization:[/bold] {account['verbose_name']} [dim]({account['name']})[/dim]", |
259 | | - ) |
| 257 | + daily_api_key = None |
| 258 | + try: |
| 259 | + daily_api_key, error = await API.organizations_daily_key(org=org, live=live) |
| 260 | + except Exception: |
| 261 | + pass |
| 262 | + |
| 263 | + live.stop() |
| 264 | + message = Columns([ |
| 265 | + "[bold]User ID[/bold]\n" |
| 266 | + "[bold]Active Organization[/bold]\n" |
| 267 | + "[bold]Daily API Key[/bold]", |
| 268 | + f"{user_data['user']['userId']}\n" |
| 269 | + f"{account['verbose_name']} [dim]({account['name']})[/dim]\n" |
| 270 | + f"{daily_api_key.get('apiKey', '[dim]N/A[/dim]') if daily_api_key else '[dim]N/A[/dim]'}", |
| 271 | + ]) |
| 272 | + console.success(message) |
260 | 273 | except Exception: |
261 | 274 | console.error("Unable to obtain user data. Please contact support") |
0 commit comments