spark/spark-cli — pull request #124 by kylemarsh (2014-12-22 06:52:57+00:00)
Title: Feature/access tokens

Implements a new set of commands to manage access tokens: can list, create, and revoke tokens. All these commands require the username and password to be reentered.

Listing tokens sorts by expiration date (longest-lived tokens first), indicates expired tokens with (expired) next to the client name, and indicates the token that this copy of the CLI is using with an *.

Revoking tokens can take multiple tokens as arguments and will only ask you for your credentials once before revoking all the specified tokens. Revoking the CLI's active token will fail unless you use "--force" in your arguments.

Creating a new token will look for the client name as an argument or default to "user".

Sample output from all three commands:

> spark token list
Checking with the cloud...
Could I please have an email address? me@domain.com
and a password? *******
spark-cli*
Token: abcdef0987654321
Expires At: 2015-03-22T02:45:32.037Z

spark-ide (expired)
Token: 1234567890abcdef
Expires At: 2014-12-20T22:36:22.704Z
>
> spark token revoke abcdef0987654321 34567890deadbeef
WARNING: abcdef0987654321 is this CLI's access token
use --force to delete it
>
> spark token revoke --force abcdef0987654321 34567890deadbeef
WARNING: abcdef0987654321 is this CLI's access token
**forcing**
Could I please have an email address? me@domain.com
and a password? *******
removing access_token abcdef0987654321
removing access_token 34567890deadbeef
successfully deleted abcdef0987654321
error revoking asdf: "invalid_request"
>
> spark token new client-name
Could I please have an email address? me@domain.com
and a password? *******
New access token expires on Sat Mar 21 2015 15:48:00 GMT-0700 (PDT)
a0b9c8d7e6f54321

All three of these commands rely on the fix in https://github.com/spark/spark-cli/pull/123 to exit cleanly -- without that patch they will continue waiting for input after the command completes until passed an End Of Transmission character (^D) or terminated.