An example oauth2 workflow for using the netatmo API.
via ssh
pip install git+ssh://git@github.com/jkittner/netatmo-auth-appvia https
pip install git+https://github.com/jkittner/netatmo-auth-app-
setup your app
- create a file called
netatmo_app.jsonwith this structure in your current working directory{ "name": "<name of the app>", "redirect_uri": "http://localhost:5000/auth-callback", "client_id": "<client_id>", "client_secret": "<client_secret>" } - set the file permissions to
-rw-------chmod 600 netatmo_app.json
- the
redirect_urimust match your netatmo app's settings
- create a file called
-
run the app
- in the terminal run to start the web app:
netatmo-auth-app
- open your browser at http://127.0.0.1:5000
- in the terminal run to start the web app:
-
log into your account
- click Login to Netatmo. You will be redirected to the Netatmo page
- Enter your email and password and click LOG IN
- Click YES, I ACCEPT to allow access to our third-party app
- You will be redirected to the local authorization app which now has an access token and a refresh token (blurred for your safety). You have to click on the blur to remove it and show the token in plain text.
- A button shows up, which you can use to refresh the token
-
a file called
.netatmo_tokenis now created in your current working directory, which will contain the access token, the refresh token, and the expiry timestamp. Make sure you never check in this file -- add it to your.gitignore -
You can use the token in your scripts like this:
from netatmo_auth_app import OAuth2Token
token = OAuth2Token.from_file()
if token.expired:
token.refresh()