New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

parse-access-token

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parse-access-token

Parse access token from request

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
56
decreased by-5.08%
Maintainers
1
Weekly downloads
 
Created
Source

parse-access-token

Parse OAuth 2.0 bearer token from request body, query param or headers.

ref: https://tools.ietf.org/html/rfc6750#section-2

Install

$ npm install --save parse-access-token

Usage

Exposes functions parseHeaderToken, parseQueryToken, parseBodyToken as named exports to parse token from headers, query or body respectively and a function as default export that check all three and throws an error if found in more than one of them. All functions return the access token if found, else undefined. Note that the access token is not verified, just parsed form the request.

ES6 module available at parse-access-token/es6 and commonjs ES5 at parse-access-token. Note: using require the default export is accessible as default:

const parseToken = require("parse-access-token").default

Works on an express, koa or hapi request object.

import parseToken from 'parse-access-token/es6'

app.get('/resource', (req, res, next) => {
  const token = parseToken(req)

  if (verify(token)) {
    res.status(200).send('Resource')
  } else {
    res.status(401).send('Unauthorized')
  }
})

FAQs

Package last updated on 26 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc