From f91967c4c8ed1466bc2363386eae411ef1faf29d Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Tue, 20 Dec 2022 08:18:38 +0100 Subject: [PATCH] improve error message for oauth --- backend/windmill-api/src/oauth2.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/backend/windmill-api/src/oauth2.rs b/backend/windmill-api/src/oauth2.rs index 55cda444d0..377c0111c4 100644 --- a/backend/windmill-api/src/oauth2.rs +++ b/backend/windmill-api/src/oauth2.rs @@ -1029,13 +1029,25 @@ async fn http_get_user_info( url: &str, token: &str, ) -> error::Result { - Ok(http_client + let res = http_client .get(url) .bearer_auth(token) .send() .await .map_err(to_anyhow) - .context("failed to fetch user info")? + .context("failed to fetch user info")?; + if !res.status().is_success() { + tracing::debug!( + "The bearer token of the failed oauth user info exchange is: {}", + token + ); + return Err(error::Error::BadConfig(format!( + "The user info endpoint responded with non 200: {}, {}", + res.status(), + res.text().await.unwrap_or_default() + ))); + } + Ok(res .json::() .await .map_err(to_anyhow)