We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 629bad6 commit eda0756Copy full SHA for eda0756
1 file changed
alertaclient/commands/cmd_token.py
@@ -1,11 +1,21 @@
1
import click
2
3
+from alertaclient.auth.token import Jwt
4
from alertaclient.auth.utils import get_token
5
6
7
@click.command('token', short_help='Display current auth token')
8
+@click.option('--decode', '-D', is_flag=True, help='Decode auth token.')
9
@click.pass_obj
-def cli(obj):
- """Display the auth token for logged in user."""
10
+def cli(obj, decode):
11
+ """Display the auth token for logged in user, with option to decode it."""
12
client = obj['client']
- click.echo(get_token(client.endpoint))
13
+ token = get_token(client.endpoint)
14
+ if decode:
15
+ jwt = Jwt()
16
+ for k, v in jwt.parse(token).items():
17
+ if isinstance(v, list):
18
+ v = ', '.join(v)
19
+ click.echo('{:20}: {}'.format(k, v))
20
+ else:
21
+ click.echo(token)
0 commit comments