oauth1-signature

1.0.5 • Public • Published

OAuth1 Signature generator

OAuth1 Signature Generator CI

Generates a valid signature for OAuth1 protected APIs

Usage

const OAuth1Signature = require('oauth1-signature');
 
const signature = OAuth1Signature({
    consumerKey: 'yourKey',
    consumerSecret: 'yourSecret',
    method: 'GET',
    url: 'https://www.signature.com',
    queryParams: {
        param1: 'paramValue',
        param2: 'paramValue',
    },
});
 
const { signature, params } = signature;
 
// Now you can use the oauth signature / params to hit your API

oauthSignature returns an object that contains:

  • signature: the oauth1 signature
  • params: the params passed to oauthSignature merged with the oauth params

Axios example Yahoo Weather API

const signature = OAuth1Signature({
    consumerKey: YAHOO_CONSUMER_KEY,
    consumerSecret: YAHOO_CONSUMER_SECRET,
    url: `${YAHOO_BASE_URL}/forecastrss`,
    method: 'GET',
    queryParams: {
        location: 'toronto',
        format: 'json',
        u: 'c',
    },
});
 
axios.request({
    baseURL: YAHOO_BASE_URL,
    url: 'forecastrss',
    params: signature.params,
});

Package Sidebar

Install

npm i oauth1-signature

Weekly Downloads

318

Version

1.0.5

License

MIT

Unpacked Size

7.85 kB

Total Files

19

Last publish

Collaborators

  • fernando-mf