@@ -1070,6 +1070,8 @@ async fn handle_status() -> Result<(), GwsError> {
10701070 // If we have credentials or a direct token, try to get live info (user, scopes, APIs)
10711071 // Skip all network calls and subprocess spawning in test builds
10721072 if !cfg ! ( test) {
1073+ let http_client = reqwest:: Client :: new ( ) ;
1074+
10731075 let direct_token = std:: env:: var ( "GOOGLE_WORKSPACE_CLI_TOKEN" )
10741076 . ok ( )
10751077 . filter ( |t| !t. is_empty ( ) ) ;
@@ -1095,7 +1097,6 @@ async fn handle_status() -> Result<(), GwsError> {
10951097 ( client_id, client_secret, refresh_token)
10961098 {
10971099 // Exchange refresh token for access token
1098- let http_client = reqwest:: Client :: new ( ) ;
10991100 let token_resp = http_client
11001101 . post ( "https://oauth2.googleapis.com/token" )
11011102 . form ( & [
@@ -1147,7 +1148,6 @@ async fn handle_status() -> Result<(), GwsError> {
11471148
11481149 if let Some ( at) = access_token {
11491150 output[ "token_valid" ] = json ! ( true ) ;
1150- let http_client = reqwest:: Client :: new ( ) ;
11511151
11521152 // Get user info
11531153 if let Ok ( user_resp) = http_client
@@ -1164,8 +1164,12 @@ async fn handle_status() -> Result<(), GwsError> {
11641164 }
11651165
11661166 // Get granted scopes via tokeninfo
1167- let tokeninfo_url = format ! ( "https://oauth2.googleapis.com/tokeninfo?access_token={}" , at) ;
1168- if let Ok ( info_resp) = http_client. get ( & tokeninfo_url) . send ( ) . await {
1167+ if let Ok ( info_resp) = http_client
1168+ . get ( "https://oauth2.googleapis.com/tokeninfo" )
1169+ . query ( & [ ( "access_token" , & at) ] )
1170+ . send ( )
1171+ . await
1172+ {
11691173 if let Ok ( info_json) = info_resp. json :: < serde_json:: Value > ( ) . await {
11701174 if let Some ( scope_str) = info_json. get ( "scope" ) . and_then ( |v| v. as_str ( ) ) {
11711175 let scopes: Vec < & str > = scope_str. split ( ' ' ) . collect ( ) ;
@@ -1176,6 +1180,7 @@ async fn handle_status() -> Result<(), GwsError> {
11761180 }
11771181 }
11781182
1183+
11791184 // Show enabled APIs if we have a project_id
11801185 if let Some ( pid) = output. get ( "project_id" ) . and_then ( |v| v. as_str ( ) ) {
11811186 let enabled = crate :: setup:: get_enabled_apis ( pid) ;
0 commit comments