bearer-token
Callback with a rfc6750 OAuth 2.0 Bearer Token from an http request object, ready for verification.
Install
npm install bearer-token
Example
var bearerToken = var http = server = httpserver server
Pass in a standard http
reuest
object to extract a single bearer token from the request in the callback, if it exists. If no bearer token is found, token
will be undefined. The first bearer token that is found is returned. Authentication headers take precidence over tokens found in the body.
Arguments
var bearerToken = require('bearer-token')
bearerToken
is a single asyncronous function.
bearerToken(req, callback)
req
Accepts a standardhttp
request object. The request header and body are parsed in search of a bearer token. Tokens found in the request header take precidence over tokens in the body.callback(error, token)
Function is called with any errors and a token if found. A missing token is not grounds for an error (only parsing or unexpected errors).error
Error object if anything bad happened.token
String if a token is found. You still need to verify it.
Contributing
Contributions welcome! Please read the contributing guidelines first.
Contributors
bcomnes | GitHub/bcomnes |
---|---|
wpacks | GitHub/wpacks |