A React component for authentication with OpenStreetMap. This is based on osm-auth created by osmlab.
Installation
npm install react-osm-auth --save
Usage
; const options = url : 'https://master.apis.dev.openstreetmap.org' oauth_consumer_key: 'your consumer key' oauth_secret: 'your secret key' auto: true; Component { console // an XML DOM of user details } { console // authInstance of osm-auth } { return <div> <ReactOSMAuth ...options onAuthenticated=thisonAuthenticated authInstance=thisauthInstance/> </div> ; }
This component exposes 'onAuthenticated' method to handle user details on authentication. 'authInstance' method acquires instance of osm-auth through which all original APIs in 'osmlab/osm-auth' can be consumed. For eg:
authInstance;
Required Landing page
For this component to work(as with osm-auth by osmlab) , you need to add a HTML landing page for the Auth Popup. The default name for the popup is 'land.html' and is also included in this repo. Add that html file in the same directory where your 'index.html' for the app resides. The "land.html" page should have the following content.
Available methods
name | type | description |
---|---|---|
onAuthenticated | function | Invoked on successful authentication of user |
authInstance | function | Acquires access to osm-auth instance |