# @bukalapak/express-bearer-token

> Bearer token middleware for express.

Latest version **3.0.1** (published 2017-10-25) · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @bukalapak/express-bearer-token
pnpm add @bukalapak/express-bearer-token
yarn add @bukalapak/express-bearer-token
bun add @bukalapak/express-bearer-token
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 3.0.1 |
| Published | 2017-10-25 |
| First published | 2017-10-25 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.10.0 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | subosito |
| Keywords | bearer token, bearer token middleware, express token, authorization bearer |

## Links

- npm: https://www.npmjs.com/package/@bukalapak/express-bearer-token
- Repository: https://github.com/bukalapak/express-bearer-token
- Issues: https://github.com/bukalapak/express-bearer-token/issues
- npm.io page: https://npm.io/package/@bukalapak/express-bearer-token

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 3.0.1 (latest) — 2017-10-25
- 3.0.0 — 2017-10-25

## README

# express-bearer-token
[![Build Status](https://travis-ci.org/bukalapak/express-bearer-token.svg?branch=master)](https://travis-ci.org/bukalapak/express-bearer-token)

> Bearer token middleware for express.

[![NPM](https://nodei.co/npm/@bukalapak/express-bearer-token.png)](https://nodei.co/npm/@bukalapak/express-bearer-token/)

## What?

Per [RFC6750] this module will attempt to extract a bearer token from a request from these locations:

* The key `access_token` in the request body.
* The key `access_token` in the request params.
* The value from the header `Authorization: Bearer <token>`. The header key is case insensitive.

If a token is found, it will be stored on `req.token`.  If one has been provided in more than one location, this will abort the request immediately by sending code 400 (per [RFC6750]).

```js
const express = require('express');
const bearerToken = require('express-bearer-token');
const app = express();

app.use(bearerToken());
app.use(function (req, res) {
  res.send('Token '+req.token);
});
app.listen(8000);
```

For APIs which are not compliant with [RFC6750], the key for the token in each location is customizable, as is the key the token is bound to on the request (default configuration shown):
```js
app.use(bearerToken({
  bodyKey: 'access_token',
  queryKey: 'access_token',
  headerKey: 'Bearer',
  reqKey: 'token'
}));
```

[RFC6750]: https://xml.resource.org/html/rfc6750

---
_Source: https://npm.io/package/@bukalapak/express-bearer-token · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
