Skip to content

Commit

Permalink
fix: invalid auth error code
Browse files Browse the repository at this point in the history
  • Loading branch information
raimundo-henriques committed May 16, 2024
1 parent 15d25f5 commit 3452895
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion endpoint/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl<'r, 'o: 'r> Responder<'r, 'o> for OAuth2ErrorMessage {
fn respond_to(self, request: &'r Request<'_>) -> response::Result<'o> {
Response::build()
.merge(Json(self).respond_to(request)?)
.status(Status::Unauthorized)
.status(Status::BadRequest)
.ok()
}
}
Expand Down
6 changes: 3 additions & 3 deletions endpoint/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ fn oauth2_create_token(
} else {
Either::Right(error::OAuth2ErrorMessage {
error_description: "Invalid client credentials",
error: "unauthorized_client",
error: "invalid_client",
})
}
}
Expand Down Expand Up @@ -520,12 +520,12 @@ fn post_auth_action_test() {
rocket::http::ContentType::JSON,
resp.content_type().unwrap()
);
assert_eq!(rocket::http::Status::Unauthorized, resp.status());
assert_eq!(rocket::http::Status::BadRequest, resp.status());

let error_response: HashMap<String, String> = resp.into_json().unwrap();
assert_eq!(
HashMap::from([
("error".to_string(), "unauthorized_client".to_string()),
("error".to_string(), "invalid_client".to_string()),
(
"error_description".to_string(),
"Invalid client credentials".to_string()
Expand Down

0 comments on commit 3452895

Please sign in to comment.