Auth¶
Summary¶
|
Get an access token using the user's iNaturalist username and password, using the Resource Owner Password Credentials Flow. |
Attempt to get iNaturalist credentials from the system keyring |
|
|
Store iNaturalist credentials in the system keyring for future use. |
Module Contents¶
- pyinaturalist.auth.get_access_token(username=None, password=None, app_id=None, app_secret=None)¶
Get an access token using the user’s iNaturalist username and password, using the Resource Owner Password Credentials Flow. Requires registering an iNaturalist app.
API reference: https://www.inaturalist.org/pages/api+reference#auth
See Authentication for additional options for storing credentials.
Examples
With direct keyword arguments:
>>> from pyinaturalist import get_access_token >>> access_token = get_access_token( >>> username='my_inaturalist_username', >>> password='my_inaturalist_password', >>> app_id='33f27dc63bdf27f4ca6cd95dd9dcd5df', >>> app_secret='bbce628be722bfe2abd5fc566ba83de4', >>> )
With environment variables or keyring configured:
>>> access_token = get_access_token()
If you would like to run custom requests for endpoints not yet implemented in pyinaturalist, you can authenticate these requests by putting the token in your HTTP headers as follows:
>>> import requests >>> requests.get( >>> 'https://www.inaturalist.org/observations/1234', >>> headers={'Authorization': f'Bearer {access_token}'}, >>> )
- pyinaturalist.auth.get_keyring_credentials()¶
Attempt to get iNaturalist credentials from the system keyring
- pyinaturalist.auth.set_keyring_credentials(username, password, app_id, app_secret)¶
Store iNaturalist credentials in the system keyring for future use.