awherepy¶
-
awherepy.
get_oauth_token
[source]¶ Returns an OAuth Token used to authenticate to the aWhere API if a valid key and secret are provided.
API reference: https://docs.awhere.com/knowledge-base-docs/authentication/
- Parameters
key (str) – API key for a valid aWhere API application.
secret (str) – API secret for a valid aWhere API application.
- Returns
access_token – Access token created from the API key and secret.
- Return type
str
Example
>>> # Imports >>> import os >>> import awherepy as aw >>> # Get aWhere API key and secret >>> awhere_api_key = os.environ.get('AWHERE_API_KEY') >>> awhere_api_secret = os.environ.get('AWHERE_API_SECRET') >>> # Get OAuth token >>> auth_token = aw.get_oauth_token(awhere_api_key, awhere_api_secret)
-
awherepy.
valid_credentials
[source]¶ Returns True if aWhere API credentials are valid, else False.
- Parameters
key (str) – API key for a valid aWhere API application.
secret (str) – API secret for a valid aWhere API application.
- Returns
valid – Boolean indicating True if API credentials are valid, else false.
- Return type
bool
Example
>>> # Imports >>> import os >>> import awherepy as aw >>> # Get aWhere API key and secret >>> awhere_api_key = os.environ.get('AWHERE_API_KEY') >>> awhere_api_secret = os.environ.get('AWHERE_API_SECRET') >>> # Check validity of credentials and get OAuth token >>> if aw.valid_credentials(awhere_api_key, awhere_api_secret): ... auth_token = aw.get_oauth_token( ... awhere_api_key, awhere_api_secret ... )