![npm version](https://badge.fury.io/js/ohauth.svg)
ohauth
A most-of-the-way OAuth 1.0 client implementation in Javascript. Meant to be
an improvement over the default linked one
because this uses idiomatic Javascript.
If you use this on a server different from the one authenticated against,
you'll need to enable and use CORS
for cross-origin resources. CORS is not available in IE before version IE10.
Demo
Try it out at: http://osmlab.github.io/ohauth/
Usage
As a file
wget https://raw.github.com/osmlab/ohauth/gh-pages/ohauth.js
With browserify
npm install ohauth
var ohauth = require('ohauth');
Compatibility
- OpenStreetMap full & tested with iD
- GitHub - partial, full flow is not possible because
access_token
API is not CORS-enabled
API
ohauth.timestamp();
ohauth.nonce();
ohauth.signature("myOauthSecret", "myTokenSecret", "percent&encoded&base&string");
ohauth.xhr(method, url, auth, data, options, callback);
{ header: { 'Content-Type': 'text/xml' } }
ohauth.xhr('POST', url, o, null, {}, function(xhr) {
});
ohauth.qsString({ foo: 'bar' });
ohauth.stringQs('foo=bar');
var auth = ohauth.headerGenerator({
consumer_key: '...',
consumer_secret: '...'
});
var header = auth('GET', 'http://.../?a=1&b=2', { c: 3, d: 4 });
var header = auth('GET', 'http://.../?a=1&b=2', 'c=3&d=4');