Authenticate with Basic auth against credentials taken from the URL
GET
https://api.testingapis.com/api/auth/basic/{user}/{pass}httpbin style: GET /api/auth/basic/foo/bar with Authorization: Basic base64(foo:bar).
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.
- 401
- Header missing, malformed or different. Includes a Basic challenge.
Example
Request
curl -X GET "https://api.testingapis.com/api/auth/basic/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/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/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/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());
}
}