---
title: "Bearer-token protected endpoint"
description: "200 when a Bearer token is sent, 401 when missing — use this to prove the Try-It Authorization header + token work."
url: "https://betterdocs.shahrear.msf.bd/index.php/docs/check-docs/check/bearer-token-protected-endpoint/"
updated: "2026-09-24"
category: Check
---

# Bearer-token protected endpoint

GET`/bearer`

## Code Samples

```curl

                curl --request GET 
  --url 'https://httpbin.org/bearer' 
  --header 'Authorization: Bearer YOUR_TOKEN'

                const response = await fetch('https://httpbin.org/bearer', {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN'
  }
});

const data = await response.json();
console.log(data);

                import requests

headers = {
    "Authorization": "Bearer YOUR_TOKEN"
}

response = requests.get("https://httpbin.org/bearer", headers=headers)

print(response.json())

                <?php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://httpbin.org/bearer',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => [
  'Authorization: Bearer YOUR_TOKEN'
  ],
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;

                using System.Net.Http;

var client = new HttpClient();
var request = new HttpRequestMessage(new HttpMethod("GET"), "https://httpbin.org/bearer");
request.Headers.Add("Authorization", "Bearer YOUR_TOKEN");
var response = await client.SendAsync(request);
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);

                import java.net.URI;
import java.net.http.*;

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://httpbin.org/bearer"))
    .header("Authorization", "Bearer YOUR_TOKEN")
    .method("GET", HttpRequest.BodyPublishers.noBody())
    .build();

HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
```

## Response

```json

                {
    "authenticated": true,
    "token": "demo-token-123"
}
```

200 when a Bearer token is sent, 401 when missing — use this to prove the Try-It Authorization header + token work.

## Responses

### 200 — Authenticated

```json

                {
    "authenticated": true,
    "token": "demo-token-123"
}
```

### 401 — Missing/invalid token
