File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change 11import click
22
3+ from alertaclient .auth .token import Jwt
34from alertaclient .auth .utils import get_token
45
56
67@click .command ('token' , short_help = 'Display current auth token' )
8+ @click .option ('--decode' , '-D' , is_flag = True , help = 'Decode auth token.' )
79@click .pass_obj
8- def cli (obj ):
9- """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 ."""
1012 client = obj ['client' ]
11- 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 )
You can’t perform that action at this time.
0 commit comments