added support for logging-in with refresh tokens, deployed as 0.0.21

main
Mark Cotton 2023-09-06 22:08:30 -05:00
parent 2d1a76b9ff
commit 38f3649a47
1 changed files with 7 additions and 4 deletions

View File

@ -1,5 +1,5 @@
""" Python client for Eagle Eye Networks APIv3 """ """ Python client for Eagle Eye Networks APIv3 """
version = "0.0.20" version = "0.0.21"
__version__ = version __version__ = version
@ -127,8 +127,7 @@ class EagleEyev3():
else: else:
return (ts - timedelta(hours=hours)).isoformat(timespec='milliseconds') return (ts - timedelta(hours=hours)).isoformat(timespec='milliseconds')
def login_tokens(self, code=None, cascade=True, refresh_token=None):
def login_tokens(self, code=None, cascade=True):
""" """
Obtains login tokens using the authorization code. Obtains login tokens using the authorization code.
@ -140,7 +139,11 @@ class EagleEyev3():
dict: Dictionary containing the success status, response HTTP status code, data, and current user information. dict: Dictionary containing the success status, response HTTP status code, data, and current user information.
""" """
baseUrl = "https://auth.eagleeyenetworks.com/oauth2/token" baseUrl = "https://auth.eagleeyenetworks.com/oauth2/token"
pathUrl = f"?grant_type=authorization_code&scope=vms.all&code={code}&redirect_uri={self.redirect_uri}" # Note the trailing slash, make sure it matches the whitelist if refresh_token:
pathUrl = f"?grant_type=refresh_token&refresh_token={refresh_token}"
else:
pathUrl = f"?grant_type=authorization_code&scope=vms.all&code={code}&redirect_uri={self.redirect_uri}" # Note the trailing slash, make sure it matches the whitelist
url = baseUrl + pathUrl url = baseUrl + pathUrl
# Send a POST request to obtain login tokens # Send a POST request to obtain login tokens