From e298a89eb8d7e416964259999ceef1282eb8a48f Mon Sep 17 00:00:00 2001 From: Mark Cotton Date: Thu, 8 Jun 2023 10:26:44 -0500 Subject: [PATCH] waiting for the new redirect_urls to be approved --- EagleEyev3/__init__.py | 2 +- server.py | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/EagleEyev3/__init__.py b/EagleEyev3/__init__.py index 745b52a..ddbef71 100644 --- a/EagleEyev3/__init__.py +++ b/EagleEyev3/__init__.py @@ -57,7 +57,7 @@ class EagleEyev3(): # Combine server_protocol, server_host, and server_port to make the redirect_uri # Note: Please see the note in settings.py about trailing slashes and modify this line if needed - self.redirect_uri = f"{settings.server_protocol}://{settings.server_host}:{settings.server_port}" + self.redirect_uri = f"{settings.server_protocol}://{settings.server_host}:{settings.server_port}/login_callback" def _save_access_token(self): with open(".lazy_login", "w") as json_file: diff --git a/server.py b/server.py index c7dd322..7277c9a 100644 --- a/server.py +++ b/server.py @@ -12,17 +12,22 @@ def index(): # This is getting the ?code= querystring value from the HTTP request. code = request.args.get('code') + base_url = "https://auth.eagleeyenetworks.com/oauth2/authorize" + path_url = f"?client_id={een.client_id}&response_type=code&scope=vms.all&redirect_uri={een.redirect_uri}" + + request_auth_url = f"{base_url}{path_url}" + + return "Login with Eagle Eye Networks" + +@app.route('/login_callback') +def login_callback(): + # This is getting the ?code= querystring value from the HTTP request. + code = request.args.get('code') + if (code): oauth_object = een.login_tokens(code) return f"Hello {een.current_user['firstName']} {een.current_user['lastName']}" - else: - base_url = "https://auth.eagleeyenetworks.com/oauth2/authorize" - path_url = f"?client_id={een.client_id}&response_type=code&scope=vms.all&redirect_uri={een.redirect_uri}" - - request_auth_url = f"{base_url}{path_url}" - - return "Login with Eagle Eye Networks" if __name__ == '__main__':