Greet an authenticated admin
GET
https://api.testingapis.com/api/Admin/authorizeGet a token from POST /api/User/Login (Michael / Thompson) and send Authorization: Bearer <token>. The role check is case-sensitive: tokens from POST /api/auth/jwt/login carry the lowercase role admin and get 403 here.
Bearer token — {{legacyJwt}}
Responses
- 200
- Greeting text.
- 401
- Token missing, invalid or expired.
- 403
- Valid token without the Admin role.
Example
Request
curl -X GET "https://api.testingapis.com/api/Admin/authorize" \
-H "Authorization: Bearer {{legacyJwt}}"Response200 OK
Content-Type: text/plain; charset=utf-8
Hi, I’m the Admin — how can I help you today?Code examples
JavaScript (fetch)
const response = await fetch("https://api.testingapis.com/api/Admin/authorize", {
headers: {
"Authorization": "Bearer {{legacyJwt}}",
},
});
console.log(response.status, await response.text());Python (requests)
import requests
response = requests.request(
"GET",
"https://api.testingapis.com/api/Admin/authorize",
headers={
"Authorization": "Bearer {{legacyJwt}}",
},
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/Admin/authorize"))
.header("Authorization", "Bearer {{legacyJwt}}")
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());
}
}