Skip to content
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

oauther

Build Status npm version

Simple OAuth 1.0 signature generation/validation.

Supports HMAC-SHA1 and PLAINTEXT signatures.

Requirements

  • Express
  • Node

Installation

npm install oauther

Usage

Initialise oauther with your secrets and use it to sign or validate requests.

var oauther = require('oauther');

var config = {
    consumer : { key : 'consumerkey', secret : 'consumersecret' },
    token : { key : 'tokenkey', secret : 'tokenkey' }, // optional
    signature_method : 'HMAC-SHA1', // 'HMAC-SHA1' (default), or 'PLAINTEXT'
    nonce_length : 32, // optional defaults to 32
    version : '1.0'  // currently only supports 1.0
};

var oauth = oauther(config);

var request = {
    hostname : 'example.com',
    path : '/oauther',
    method : 'GET'
};

var signature = oauth.sign(request);

// header formatted signature
req.header('Authorization', signature.toHeader());

// query formatted signature
var query = signature.toQuery();

// oauth parameters as json object
var params = signature.toObject();
...

// validate an incoming request
if (oauth.validate(req)) {
  console.log('Valid!');
}

Signing Requests

Request data needs to be passed to the sign method:

var request = {
    hostname : 'example.com',
    method : 'GET',
    path : '/path/to/url',
    port : 80, // optional
    protocol : 'http', // optional, default 'http'
    query, : { 'gaius' : 'baltar' },// optional, query string as json
    body : { 'kara' : 'thrace' } // optional, form encoded body as json
};

Notes

TODO: Add support for RSA-SHA1. Add support for plain Node.js http.

About

Node OAuth Module

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages