Flask example app for https://dev.mapping.team using https://docs.authlib.org/en/latest/client/flask.html and the related
loginpass library. Mapping Teams implements the OAuth 2 and OpenID Connect standards.
The OAuth 1 transaction with OpenStreetMap.org to verify the user is handled entirely over on the Mapping Teams server. After a successful login all the way through, a
user_info object is passed through to your app, and the OAuth 2
token is added.
This example will use the app credentials you provide. For the users of this demo app, authentication will be verified by Mapping Teams. Then, the access key will be available which can be used as a bearer authentication header to e.g. create a new team at https://dev.mapping.team.
- Add a name for your app
- The callback will be
http://localhost:5555/mappingteam/author whatever URL this example is running on
- Click on "Add new App" to receive your credentials
- The MAPPINGTEAM_CLIENT_ID is the
client_idreturned by the site
- The MAPPINGTEAM_CLIENT_SECRET is the
client_secretreturned by the site
- Repeat for your live server, and remember to match the HTTP/HTTPS carefully.
- clone this repository
git clone firstname.lastname@example.org:thadk/osm-teams-python-example.git; cd osm-teams-python-example
python3 -m venv flask_venvto create a new python venv environment.
. flask_venv/bin/activateto enter the environment
pip install -r requirements.txtto install the needed packages.
- Create a new localhost testing app at https://dev.mapping.team and keep the secret and ID information somewhere safe that you get when you create it. For the Callback Address, you should put in something like
http://localhost:5555/mappingteam/auth– that is the callback Flask endpoint configured by
FLASK_APP=flask_example FLASK_ENV=development MAPPINGTEAM_CLIENT_ID= MAPPINGTEAM_CLIENT_SECRET= flask run -p 5555, to start your app. Be sure to add the actual values for the Client ID and Secret you got from https://dev.mapping.team . You will not need the Client Name.
- Create a new internet testing app at https://dev.mapping.team and keep the secret and ID information somewhere safe that you get when you create it. You should use
https://yourherokudomain.herokuapp.com/mappingteam/authas the callback address, updating the domain as needed to match the app you just created.
heroku config:set MAPPINGTEAM_CLIENT_ID= MAPPINGTEAM_CLIENT_SECRET=, entering in the Client ID and Secret you just got for your internet testing app.
git push heroku master
- Try out your app using your Heroku address. It should look something like the on at https://polar-island-94689.herokuapp.com/
An unfinished Django example is available on the Django_example branch, ready to follow the instructions with the loginpass library to use it. https://github.com/thadk/osm-teams-python-example/tree/django_example . The Loginpass example app may also be helpful: https://github.com/authlib/loginpass/tree/master/django_example