Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maxfi/microauth-token
Token auth wrapper for zeit/micro
https://github.com/maxfi/microauth-token
Last synced: 1 day ago
JSON representation
Token auth wrapper for zeit/micro
- Host: GitHub
- URL: https://github.com/maxfi/microauth-token
- Owner: maxfi
- License: mit
- Created: 2018-02-26T11:50:53.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-01T23:18:16.000Z (almost 2 years ago)
- Last Synced: 2024-10-06T20:06:06.789Z (about 1 month ago)
- Language: JavaScript
- Size: 532 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# microauth-token
> Token auth wrapper for zeit/micro
Unfortunately not all third-parties are able or willing to add the `Authorization` header to a request, especially with webhooks. However, it's possible to add a token to the query string and use that for authorizing requests.
## Install
With [npm](https://npmjs.org/) installed, run
```
$ npm install microauth-token
```## Usage
With a [`micro`](https://github.com/zeit/micro) project:
```js
// index.js
const auth = require('microauth-token')module.exports = auth('TOKEN')((req, res) => {
res.end('Authorized')
})
``````sh
$ TOKEN=abc micro
``````sh
$ curl localhost:3000?TOKEN=abc # => '200 Authorized'
$ curl localhost:3000?TOKEN=xyz # => '401 Unauthorized'
```## License
MIT