vangorra / python_withings_api

Library for the Withings Health API
MIT License
101 stars 34 forks source link

How to use from a script? #59

Closed crhuber closed 3 years ago

crhuber commented 3 years ago

Thanks for the great module. How would one use this in a script to get my own measurements? Once I have the credentials, can I continue to use them in a long lived process? For example, once Ive gone through the oauth steps can I continue to use those creds to get measurements at a later date?

vangorra commented 3 years ago

The integration test demonstrates how to retrieve data and persist credentials between runs. The integration test is only one example, implementation of credential storage or process longevity depends on your needs.

With oauth, refreshing credentials is necessary but automatically handled by the code. If you request data every hour, the token will be refreshed. You are responsible for storing those updated credentials. The callback for credential changes is provided as an argument to the WithingsApi class.