---
title: bearer
description: "Make the `auth` of an `http` Effect that sends `Authorization: Bearer <value>`, with the value of an Effect secret."
---

# `bearer`

Function, in `@jr2/orchestrator/src/http-effect.ts`. It is an export of `@jr2/orchestrator`, on the [Authoring surface](../authoring-surface.md) page, in Effects.

```ts
function bearer<const S extends Secret>(s: S): MarkedIf<S, { readonly bearer: Secret }>
```

Make the `auth` of an `http` Effect that sends `Authorization: Bearer <value>`, with the value
of an Effect secret. In a packaged Machine, the secret can be `secret(open)`.

It refuses a value that is not a secret: `bearer(…) takes a secret("name")`.

**Parameters**

- `s` ([`Secret`](type-secret.md)): The secret: `secret("name")`, or `secret(open)`.

**Returns**: The `auth` of an `http` Effect.

**Example**

```ts
import { bearer, http, jr2Setup, secret } from "@jr2/orchestrator";

export const machine = jr2Setup({
  actors: {
    status: http({
      method: "GET",
      url: "https://api.github.com/repos/you/app",
      auth: bearer(secret("github")),
    }),
  },
}).createMachine({
  id: "status",
  initial: "reading",
  states: {
    reading: { invoke: { src: "status", onDone: "done" } },
    done: { type: "final" },
  },
});
```

**See also**

- [Run a command or call a URL with an Effect](../../guides/run-a-command-or-call-a-url.md)
- [Secrets and trust](../../concepts/secrets-and-trust.md)
- [ADR-0068: An Effector holds an Effect's secrets and signs its wire](../decisions/0068-an-effector-holds-an-effects-secrets-and-signs-its-wire.md)
- [ADR-0054: The kit ships Machines, and a shipped Machine leaves its parts Open](../decisions/0054-the-kit-ships-machines-and-a-shipped-machine-leaves-its-parts-open.md)
