1.0.5 • Published 4 years ago

oauth1-signature v1.0.5

Weekly downloads
95
License
MIT
Repository
github
Last release
4 years ago

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,
});
1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago