diff options
author | Jesse Morgan <jesse@jesterpm.net> | 2025-03-02 15:48:51 -0800 |
---|---|---|
committer | Jesse Morgan <jesse@jesterpm.net> | 2025-03-02 15:48:51 -0800 |
commit | 5f37e7663dfc7e87cf8a88a85c68eb681fa5bd4f (patch) | |
tree | ed14fda421dc4918a775945b385e4ea8d381ecc8 | |
parent | 9d4e3dc0c1b7a40da64b9c38015e8628ff624ed9 (diff) |
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | src/bin/sso/main.rs | 18 |
2 files changed, 15 insertions, 4 deletions
@@ -16,3 +16,4 @@ Options: Commands: login - default: get or renew an access token curl - pass the access token to curl + token - print the current bearer token diff --git a/src/bin/sso/main.rs b/src/bin/sso/main.rs index 0356f3d..2e22198 100644 --- a/src/bin/sso/main.rs +++ b/src/bin/sso/main.rs @@ -60,9 +60,9 @@ enum Commands { /// Request or refresh an access token (default command). Login, /// Send a curl request with an authorization header. - Curl { - args: Vec<String>, - }, + Curl { args: Vec<String> }, + /// Print the current bearer token. + Token, } #[derive(Serialize, Deserialize, Clone)] @@ -301,7 +301,7 @@ fn main() -> Result<(), Box<dyn Error>> { if command == Commands::Login || !profile.valid_access_token() { if profile.valid_refresh_token() { // Try a refresh... - // Ignore any errors + // Ignore any errors if let Err(e) = profile.refresh() { log::info!("Failed to refresh token: {}", e); } @@ -322,5 +322,15 @@ fn main() -> Result<(), Box<dyn Error>> { Ok(()) /* No-op, we already took care of it above */ } Commands::Curl { args } => do_curl(&profile, args), + Commands::Token => { + println!( + "{}", + profile + .access_token + .as_deref() + .expect("Must have valid access token") + ); + Ok(()) + } } } |