Authenticate with Basic auth, returning 404 instead of 401 on failure
GET
https://api.testingapis.com/api/auth/basic-hidden/{user}/{pass}Mimics servers that hide protected resources. No WWW-Authenticate challenge is sent.
HTTP Basic — apibee / password123
Parameters 2
| Name | Type | Description |
|---|---|---|
userrequired | path · string | Username the Authorization header must contain. |
passrequired | path · string | Password the Authorization header must contain. |
Responses
- 200
- Header matches the URL credentials.
- 404
- Header missing, malformed or different.
Example
Request
curl -X GET "https://api.testingapis.com/api/auth/basic-hidden/apibee/password123" \
-H "Authorization: Basic YXBpYmVlOnBhc3N3b3JkMTIz"Response200 OK
{"authenticated": true, "scheme": "basic", "user": "apibee"}Code examples
JavaScript (fetch)
const response = await fetch("https://api.testingapis.com/api/auth/basic-hidden/apibee/password123", {
headers: {
"Authorization": "Basic YXBpYmVlOnBhc3N3b3JkMTIz",
},
});
console.log(response.status, await response.text());Python (requests)
import requests
response = requests.request(
"GET",
"https://api.testingapis.com/api/auth/basic-hidden/apibee/password123",
headers={
"Authorization": "Basic YXBpYmVlOnBhc3N3b3JkMTIz",
},
allow_redirects=False,
)
print(response.status_code, response.text)Java (HttpClient)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newBuilder()
.followRedirects(HttpClient.Redirect.NEVER)
.build();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.testingapis.com/api/auth/basic-hidden/apibee/password123"))
.header("Authorization", "Basic YXBpYmVlOnBhc3N3b3JkMTIz")
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());
}
}