# `BearerToken`

An access token sent as `Authorization: Bearer`.

Use it for such a token on an outside call or an incoming request. Keep `hash.sha256` of it, not the token. For a signed token you can read, use [`Jwt`](/docs/types/type-jwt.md).

## Shape

One secret value, with no parts.

## Example

```jadpo
BearerToken("mF_9.B5f-4.1JqM")
```

In a real app it arrives from outside, such as in a request, rather than as text you write in your code.

`text.parse(raw, as: BearerToken)` reads one from text that comes from outside. Text that isn't one at all fails `malformed`, such as `mF_9 B5f`, `mF=9` or `mF_9!B5f`.

## Good to know

- It is never logged, stored or shown, and a response never sends it.
- `==` tells you whether two are the same. `<` and `list.sort_by` don't take it.

## In JSON

A string when it arrives, and written redacted when it leaves, in a request, a response or `json.write`:

```json
"<redacted BearerToken>"
```

## Details

<details>
<summary>Text form, storage, how it is shown, and operations</summary>

`BearerToken` is in the group Security, and has been in Jadpo since 0.1.0.

### Text form

`text.parse` reads one from its text as it is typed. `text.from` and `text.format` don't take it, so nothing writes it.

### How it is stored

It is never stored.

### How it is shown to people

`text.format` doesn't take it: a `BearerToken` is never shown.

### Operations

It also takes `text.parse`, `json.read`, `json.write` and `==`. [How every standard type behaves](/docs/every-standard-type-meets-one-contract.md) says how they work.

</details>
