summaryrefslogtreecommitdiff
path: root/src/bin/sso/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/sso/main.rs')
-rw-r--r--src/bin/sso/main.rs18
1 files changed, 14 insertions, 4 deletions
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(())
+ }
}
}