11mod api;
2- mod auth;
32mod cli;
43mod commands;
54mod config;
@@ -8,7 +7,7 @@ use std::process;
87
98use clap:: Parser ;
109
11- use api:: client :: AuthCredentials ;
10+ use api:: auth :: AuthCredentials ;
1211use api:: ApiClient ;
1312use cli:: Cli ;
1413
@@ -28,22 +27,9 @@ async fn main() {
2827 // Build auth credentials and get initial token if configured
2928 let ( token, auth_credentials) =
3029 if let Some ( ( sso_url, client_id, client_secret) ) = cli. config . auth_credentials ( ) {
31- let token_url = if sso_url. ends_with ( "/token" ) {
32- sso_url. to_string ( )
33- } else if sso_url. ends_with ( '/' ) {
34- format ! ( "{}protocol/openid-connect/token" , sso_url)
35- } else {
36- format ! ( "{}/protocol/openid-connect/token" , sso_url)
37- } ;
30+ let creds = AuthCredentials :: new ( sso_url, client_id, client_secret) ;
3831
39- // Store credentials for token refresh
40- let creds = AuthCredentials {
41- token_url : token_url. clone ( ) ,
42- client_id : client_id. to_string ( ) ,
43- client_secret : client_secret. to_string ( ) ,
44- } ;
45-
46- match auth:: get_token ( & token_url, client_id, client_secret) . await {
32+ match creds. get_token ( ) . await {
4733 Ok ( token) => ( Some ( token) , Some ( creds) ) ,
4834 Err ( e) => {
4935 eprintln ! ( "Error: {}" , e) ;
0 commit comments