go-fetch-auth

3.0.0 • Public • Published

go-fetch-auth

Build Status

A go-fetch plugin for authenticating requests.

Installation

npm install --save go-fetch-auth

Usage

const Client = require('go-fetch');
const auth = require('go-fetch-auth');
 
new Client()
  .use(auth.basic('steve.jobs', 'l33tH@ck3r'))
  .get('http://httpbin.org/hidden-basic-auth/steve.jobs/l33tH@ck3r')
    .then(res => {
      console.log(res.status);
      return res.text();
    })
    .then(text => console.log(text))
    .catch(err => console.error(err.stack))
;
 

API

auth.basic(username, password)

Authenticate each request using the Basic scheme for HTTP authentication.

Parameters:

  • username : string Required. The username.
  • password : string Required. The password.

Returns:

A plugin instance.

auth.bearer(token)

Authenticate each request using the Bearer scheme for HTTP authentication.

Parameters:

  • token : string Required. The token.

Returns:

A plugin instance.

/go-fetch-auth/

    Package Sidebar

    Install

    npm i go-fetch-auth

    Weekly Downloads

    6

    Version

    3.0.0

    License

    MIT

    Last publish

    Collaborators

    • jameslnewell