From OpenStreetMap Wiki
Jump to: navigation, search
Available languages — OAuth
Afrikaans Alemannisch aragonés asturianu azərbaycanca Bahasa Indonesia Bahasa Melayu Bân-lâm-gú Basa Jawa Baso Minangkabau bosanski brezhoneg català čeština dansk Deutsch eesti English español Esperanto estremeñu euskara français Frysk Gaeilge Gàidhlig galego Hausa hrvatski Igbo interlingua Interlingue isiXhosa isiZulu íslenska italiano Kiswahili Kreyòl ayisyen kréyòl gwadloupéyen kurdî latviešu Lëtzebuergesch lietuvių magyar Malagasy Malti Nederlands Nedersaksies norsk norsk nynorsk occitan Oromoo oʻzbekcha/ўзбекча Plattdüütsch polski português română shqip slovenčina slovenščina Soomaaliga suomi svenska Tiếng Việt Türkçe Vahcuengh vèneto Wolof Yorùbá Zazaki српски / srpski беларуская български қазақша македонски монгол русский тоҷикӣ українська Ελληνικά Հայերեն ქართული नेपाली मराठी हिन्दी অসমীয়া বাংলা ਪੰਜਾਬੀ ગુજરાતી ଓଡ଼ିଆ தமிழ் తెలుగు ಕನ್ನಡ മലയാളം සිංහල ไทย မြန်မာဘာသာ ລາວ ភាសាខ្មែរ ⵜⴰⵎⴰⵣⵉⵖⵜ አማርኛ 한국어 日本語 中文(简体)‎ 吴语 粵語 中文(繁體)‎ ייִדיש עברית اردو العربية پښتو سنڌي فارسی ދިވެހިބަސް

OAuth on OpenStreetMap is a mechanism which allows users to authorise third party applications to do things with their OSM user account - without that application handling the user's password. The User Credentials Policy recommends application developers should use OAuth in preference to HTTP Basic Auth or other methods for access to the API.

Usage for developers

You can register your Consumer application on your OpenStreetMap user settings page via the OAuth settings link at the top of the page.

Here are the relevant URLs for reference:

For development and testing purposes, the API instance on the dev server also has OAuth endpoints. Their URLs are:

Make sure, to use the dev server API, you have created an account in dev server also. The Live server and Dev server DO NOT share the same database. So you need to create an account with new username and password and use its consumer secret and key.

A few more details:

  • OpenStreetMap supports OAuth 1.0 and 1.0a but 1.0a should be used for any new application, as 1.0 is for certain legacy clients only.
  • Access tokens currently do not expire automatically

The basic idea

An application, for example JOSM, or a website, for example OpenCycleMap could receive permission to make edits to OpenStreetMap data with the user's account.

OAuth is used by some other sites such as twitter and flickr. If you use a flickr uploader app for example, you can see how the authorisation would work from a user perspective. When you try to use the app, it needs to direct the user to the website, where you log in as usual, and then grant permissions. The app then receives a token which it can use in its requests. It eliminates the need for the app to know about the user's login credentials. Nifty.


Oauth is live on production.

See OAuth examples for code snippets and links to working tools' source code in various languages, to help you create OpenStreetMap OAuth clients.

Registering your application as OAuth consumer

Before an application can use the OAuth protocol to gain authorized access to the protected resources on the OSM server it has to be registered as OAuth consumer. Every registered user can register applications as consumer.

  1. Login to your account
  2. Go to [1]

In the following form you have to enter four parameters:

  • Name - this is the display name of your application. Which will be presented to the user.
  • Main Application URL (Required) - this is an information URL with information about your application. It isn't related to the OAuth protocol at all. When a user authorises access from your application on the OSM website, the OSM website will display a link <a href="info-url-to-your-app">Name of your App</a>.
  • Callback URL - if you register a web application you can enter a callback URL the OSM website will invoke redirect the user at the end of the OAuth handshake. The URL is optional. Leave it empty if your web application doesn't provide a callback URL. If you are registering a rich client application then either leave it empty or point it to a page that says something like "now close the browser and go back to the application".
  • Support URL - leave it empty. I have no idea what it is used for.

Basics of the protocol

  1. you register your application (consumer) and supply CONSUMER_KEY + CONSUMER_SECRET into it
  2. some user runs your application, it calls Request Token URL and receives: oauth_token + oauth_token_secret
  3. then it redirects the user to Authorize URL + '?oauth_token=' + oauth_token
  4. user logs in on OpenStreetMap.org, the site asks them to grant permissions
  5. if callback url is supplied during registration, user is redirected to Callback URL + '?oauth_token=' + the_same_oauth_token + '&oauth_verifier=' + verifier_needed_to_retreive_access_token
  6. your application gets the same oauth_token, calls Access Token URL and receives: access_token + access_token_secret
  7. access token and its secret are used for further communication

Extra notes

External Resources