| ... | @@ -97,6 +97,12 @@ fn registration(auth: &auth::Store, provider: &str) -> Result<(String, String)> | ... | @@ -97,6 +97,12 @@ fn registration(auth: &auth::Store, provider: &str) -> Result<(String, String)> |
| 97 | | 97 | |
| 98 | async fn response_bytes(mut response: reqwest::Response) -> Result<Vec<u8>> { | 98 | async fn response_bytes(mut response: reqwest::Response) -> Result<Vec<u8>> { |
| 99 | if !response.status().is_success() || response.content_length().is_some_and(|n| n > 65536) { | 99 | if !response.status().is_success() || response.content_length().is_some_and(|n| n > 65536) { |
| | 100 | eprintln!( |
| | 101 | "guest provider response: {} {} status {}", |
| | 102 | response.url().host_str().unwrap_or_default(), |
| | 103 | response.url().path(), |
| | 104 | response.status() |
| | 105 | ); |
| 100 | return Err(Error::new( | 106 | return Err(Error::new( |
| 101 | 502, | 107 | 502, |
| 102 | "The provider couldn't complete sign-in. Return to Shale and try again.", | 108 | "The provider couldn't complete sign-in. Return to Shale and try again.", |
| ... | @@ -242,6 +248,7 @@ async fn exchange( | ... | @@ -242,6 +248,7 @@ async fn exchange( |
| 242 | flow: &Value, | 248 | flow: &Value, |
| 243 | ) -> Result<(String, String)> { | 249 | ) -> Result<(String, String)> { |
| 244 | let form = [ | 250 | let form = [ |
| | 251 | ("client_id", client), |
| 245 | ("grant_type", "authorization_code"), | 252 | ("grant_type", "authorization_code"), |
| 246 | ("code", code), | 253 | ("code", code), |
| 247 | ("redirect_uri", callback), | 254 | ("redirect_uri", callback), |
| ... | @@ -249,7 +256,7 @@ async fn exchange( | ... | @@ -249,7 +256,7 @@ async fn exchange( |
| 249 | ]; | 256 | ]; |
| 250 | if provider == "github" { | 257 | if provider == "github" { |
| 251 | let mut form = form.to_vec(); | 258 | let mut form = form.to_vec(); |
| 252 | form.extend([("client_id", client), ("client_secret", secret)]); | 259 | form.push(("client_secret", secret)); |
| 253 | let token = json_bytes( | 260 | let token = json_bytes( |
| 254 | &response_bytes( | 261 | &response_bytes( |
| 255 | http.post("https://github.com/login/oauth/access_token") | 262 | http.post("https://github.com/login/oauth/access_token") |