Skip to content

Commit c5291fb

Browse files
Merge pull request #44 from Infisical/daniel/unsupported-media-type
fix: Potential fix for rare unsupported media bug
2 parents a95b3f8 + 56968bd commit c5291fb

File tree

3 files changed

+6
-27
lines changed

3 files changed

+6
-27
lines changed

crates/infisical/src/api/auth/mod.rs

+4-20
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,7 @@ pub(self) async fn auth_infisical_google(
4848
jwt: Option<String>,
4949
) -> Result<reqwest::Response> {
5050
let url = format!("{}/api/v1/auth/gcp-auth/login", client.site_url.clone());
51-
let request_client = build_base_request(client, &url, reqwest::Method::POST).await?;
52-
53-
let request = request_client
54-
.header(reqwest::header::ACCEPT, "application/json")
55-
.header(reqwest::header::USER_AGENT, client.user_agent.clone());
51+
let request = build_base_request(client, &url, reqwest::Method::POST).await?;
5652

5753
let mut body = HashMap::new();
5854
body.insert("identityId", identity_id);
@@ -69,11 +65,7 @@ pub(self) async fn auth_infisical_azure(
6965
jwt: Option<String>,
7066
) -> Result<reqwest::Response> {
7167
let url = format!("{}/api/v1/auth/azure-auth/login", client.site_url.clone());
72-
let request_client = build_base_request(client, &url, reqwest::Method::POST).await?;
73-
74-
let request = request_client
75-
.header(reqwest::header::ACCEPT, "application/json")
76-
.header(reqwest::header::USER_AGENT, client.user_agent.clone());
68+
let request = build_base_request(client, &url, reqwest::Method::POST).await?;
7769

7870
let mut body = HashMap::new();
7971
body.insert("identityId", identity_id);
@@ -93,11 +85,7 @@ pub(self) async fn auth_infisical_kubernetes(
9385
"{}/api/v1/auth/kubernetes-auth/login",
9486
client.site_url.clone()
9587
);
96-
let request_client = build_base_request(client, &url, reqwest::Method::POST).await?;
97-
98-
let request = request_client
99-
.header(reqwest::header::ACCEPT, "application/json")
100-
.header(reqwest::header::USER_AGENT, client.user_agent.clone());
88+
let request = build_base_request(client, &url, reqwest::Method::POST).await?;
10189

10290
let mut body = HashMap::new();
10391
body.insert("identityId", identity_id);
@@ -123,7 +111,7 @@ pub(self) async fn auth_infisical_aws(
123111
let request_body = base64_encode(iam_data.iam_request_body.clone());
124112

125113
let url = format!("{}/api/v1/auth/aws-auth/login", client.site_url.clone());
126-
let request_client = build_base_request(client, &url, reqwest::Method::POST).await?;
114+
let request = build_base_request(client, &url, reqwest::Method::POST).await?;
127115

128116
let mut form_data = HashMap::new();
129117

@@ -132,10 +120,6 @@ pub(self) async fn auth_infisical_aws(
132120
form_data.insert("iamRequestBody", Some(request_body));
133121
form_data.insert("iamRequestHeaders", Some(iam_headers));
134122

135-
let request = request_client
136-
.header(reqwest::header::ACCEPT, "application/json")
137-
.header(reqwest::header::USER_AGENT, client.user_agent.clone());
138-
139123
let response = request.form(&form_data).send().await?;
140124

141125
return Ok(response);

crates/infisical/src/api/auth/universal_auth_login.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,7 @@ pub async fn universal_auth_login(
2424
client.site_url.clone()
2525
);
2626

27-
let request_client = build_base_request(client, &url, reqwest::Method::POST).await?;
28-
29-
let request = request_client
30-
.header(reqwest::header::CONTENT_TYPE, "application/json")
31-
.header(reqwest::header::ACCEPT, "application/json")
32-
.header(reqwest::header::USER_AGENT, client.user_agent.clone());
27+
let request = build_base_request(client, &url, reqwest::Method::POST).await?;
3328

3429
let response = request.body(request_body).send().await?;
3530

crates/infisical/src/helper.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ pub async fn build_base_request(
251251
// Setting JSON as the content type is OK since we only work with JSON.
252252
.header(reqwest::header::CONTENT_TYPE, "application/json")
253253
.header(reqwest::header::ACCEPT, "application/json")
254-
.header("Authorization", token)
254+
.header(reqwest::header::AUTHORIZATION, token)
255255
.header(reqwest::header::USER_AGENT, client.user_agent.clone());
256256

257257
Ok(base_request)

0 commit comments

Comments
 (0)