diff --git a/v-api/src/endpoints/login/oauth/flow/device_token.rs b/v-api/src/endpoints/login/oauth/flow/device_token.rs index f9d4161..ee608fa 100644 --- a/v-api/src/endpoints/login/oauth/flow/device_token.rs +++ b/v-api/src/endpoints/login/oauth/flow/device_token.rs @@ -79,6 +79,7 @@ pub struct DeviceAuthorizationResponse { /// The end-user verification code displayed to the user. pub user_code: String, /// The end-user verification URI on the authorization server. + #[serde(alias = "verification_url")] pub verification_uri: Url, /// Optional verification URI that includes the user_code. #[serde(default)] @@ -92,7 +93,7 @@ pub struct DeviceAuthorizationResponse { } /// Body sent to the upstream provider's device authorization endpoint. -#[derive(Serialize)] +#[derive(Debug, Serialize)] struct UpstreamDeviceAuthzRequest { client_id: String, #[serde(skip_serializing_if = "Option::is_none")] @@ -152,6 +153,11 @@ where scope: Some(provider.default_scopes().join(" ")), }; + tracing::trace!( + ?upstream_request, + "Sending device authorization request to upstream provider" + ); + let response = client .request(Method::POST, &device_info.remote.device_code_endpoint) .header(header::CONTENT_TYPE, "application/x-www-form-urlencoded") @@ -178,8 +184,10 @@ where // Parse the upstream device authorization response let device_authz: DeviceAuthorizationResponse = serde_json::from_slice(&bytes).map_err(|err| { + let body = String::from_utf8_lossy(&bytes); tracing::error!( ?err, + ?body, "Failed to parse upstream device authorization response" ); internal_error("Failed to parse upstream device authorization response") diff --git a/v-api/src/endpoints/login/oauth/mod.rs b/v-api/src/endpoints/login/oauth/mod.rs index daa3f40..b7a7b72 100644 --- a/v-api/src/endpoints/login/oauth/mod.rs +++ b/v-api/src/endpoints/login/oauth/mod.rs @@ -129,6 +129,10 @@ where let mut responses = vec![]; for endpoint in self.user_info_endpoints() { + tracing::trace!( + ?endpoint, + "Requesting user information from OAuth provider endpoint" + ); let mut request = Request::new(Method::GET, endpoint.parse().unwrap()); self.initialize_headers(&mut request); @@ -144,8 +148,10 @@ where tracing::trace!(?status, "Received response from OAuth provider"); if !status.is_success() { + let body = response.text().await.unwrap_or_default(); tracing::error!( ?status, + ?body, endpoint, "User info endpoint returned non-success status" );