All Projects → osmlab → ohauth

osmlab / ohauth

Licence: ISC license
Pure-browser OAuth for CORS-supporting sites like OpenStreetMap

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to ohauth

oauth1-signer-nodejs
Zero dependency library for generating a Mastercard API compliant OAuth signature.
Stars: ✭ 26 (+36.84%)
Mutual labels:  oauth1
LightOSM.jl
A Julia package for downloading and analysing geospatial data from OpenStreetMap APIs.
Stars: ✭ 32 (+68.42%)
Mutual labels:  openstreetmap
Instagram
[READ ONLY] Subtree split of the SocialiteProviders/Instagram Provider (see SocialiteProviders/Providers)
Stars: ✭ 34 (+78.95%)
Mutual labels:  oauth1
osm-gis-export
Export OSM data to GIS formats like Shapefiles, Spatialite or PostGIS.
Stars: ✭ 20 (+5.26%)
Mutual labels:  openstreetmap
idly
Collection of OSM related tools
Stars: ✭ 18 (-5.26%)
Mutual labels:  openstreetmap
oauth1-signer-ruby
Zero dependency library for generating a Mastercard API compliant OAuth signature.
Stars: ✭ 15 (-21.05%)
Mutual labels:  oauth1
OpenNameSearch
Script for Building a Basic Nominatim Server
Stars: ✭ 14 (-26.32%)
Mutual labels:  openstreetmap
vectorpipe
Convert Vector data to VectorTiles with GeoTrellis.
Stars: ✭ 64 (+236.84%)
Mutual labels:  openstreetmap
osmose-backend
Part of osmose that runs the analysis, and send the results to the frontend.
Stars: ✭ 74 (+289.47%)
Mutual labels:  openstreetmap
basemaps
A lightweight package for accessing basemaps from open sources in R 🗺️
Stars: ✭ 39 (+105.26%)
Mutual labels:  openstreetmap
timeshape
Java library to find timezone based on geo coordinates
Stars: ✭ 116 (+510.53%)
Mutual labels:  openstreetmap
osm4scala
Scala and Spark library focused on reading OpenStreetMap Pbf files.
Stars: ✭ 62 (+226.32%)
Mutual labels:  openstreetmap
Twitter
[READ ONLY] Subtree split of the SocialiteProviders/Twitter Provider (see SocialiteProviders/Providers)
Stars: ✭ 21 (+10.53%)
Mutual labels:  oauth1
osmdata
Scripts for creating OSM data derived data sets
Stars: ✭ 20 (+5.26%)
Mutual labels:  openstreetmap
coin-map-android
Easily find places to spend sats anywhere on the planet
Stars: ✭ 23 (+21.05%)
Mutual labels:  openstreetmap
maproulette2
MapRoulette back-end / API
Stars: ✭ 46 (+142.11%)
Mutual labels:  openstreetmap
literan-moscow
No description or website provided.
Stars: ✭ 18 (-5.26%)
Mutual labels:  openstreetmap
Osmunda
An offline geocode library for android, powered by SQLite, using osm data. 离线地理编码Android库,基于SQLite,使用开放街道地图数据。
Stars: ✭ 37 (+94.74%)
Mutual labels:  openstreetmap
openfairdb
Open Fair DB is the CreativCommons Backend of Kartevonmorgen.org
Stars: ✭ 53 (+178.95%)
Mutual labels:  openstreetmap
osmcz
JS mapová appka pro openstreetmap.cz (osmcz-app)
Stars: ✭ 35 (+84.21%)
Mutual labels:  openstreetmap

build npm version

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

// generates an oauth-friendly timestamp
ohauth.timestamp();

// generates an oauth-friendly nonce
ohauth.nonce();

// generate a signature for an oauth request
ohauth.signature("myOauthSecret", "myTokenSecret", "percent&encoded&base&string");

// make an oauth request.
ohauth.xhr(method, url, auth, data, options, callback);

// options can be a header like
{ header: { 'Content-Type': 'text/xml' } }

ohauth.xhr('POST', url, o, null, {}, function(xhr) {
    // xmlhttprequest object
});

// generate a querystring from an object
ohauth.qsString({ foo: 'bar' });
// foo=bar

// generate an object from a querystring
ohauth.stringQs('foo=bar');
// { foo: 'bar' }

Just generating the headers

// create a function holding configuration
var auth = ohauth.headerGenerator({
    consumer_key: '...',
    consumer_secret: '...'
});

// pass just the data to produce the OAuth header with optional
// POST data (as long as it'll be form-urlencoded in the request)
var header = auth('GET', 'http://.../?a=1&b=2', { c: 3, d: 4 });
// or pass the POST data as an form-urlencoded
var header = auth('GET', 'http://.../?a=1&b=2', 'c=3&d=4');
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].