⚠️

osm-auth

3.2.0 • Public • Published

build npm version

osm-auth

Easy authentication with OpenStreetMap over OAuth 2.0.
See also: https://wiki.openstreetmap.org/wiki/OAuth

[!IMPORTANT] Due to security changes on 8 July 2025, authentication using the popup mode will not work until you:

  1. update this library to >= v3.0.0
  2. AND update the code snippet in your land.html file to the latest version (see this example)

Note that openstreetmap.org currently only supports OAuth2.0. OAuth1.0 is turned off. If you want the older version of this library that supports OAuth 1.0a (e.g. for a sister project that uses an older OSM-stack), use the v1 branch and pin your software to older release versions <2. Going forward, the v1 branch will receive limited attention.

Demo

Try it out now at: https://osmlab.github.io/osm-auth/

Or you can run the demo locally by cloning this project, then run:

$ bun install
$ bun run all
$ bun start

This will start a local server on port 8080. Then open http://127.0.0.1:8080/ in a browser.

Usage

Use in Node

To install osm-auth as a dependency in your Node project:

$  npm install --save osm-auth

osm-auth is distributed in CJS and ESM module formats for maxmimum compatibility. (Read more about Javascript module formats)

const osmAuth = require('osm-auth').osmAuth;   // CJS named import
// or
import { osmAuth } from 'osm-auth';   // ESM named import

Use in Browsers

You can also use osm-auth directly in a web browser. A good way to do this is to fetch the "iife" bundle from the jsDelivr CDN, which can even deliver minified versions.

When you load this file in a