waiting for the new redirect_urls to be approved

full_example
Mark Cotton 2023-06-08 10:26:44 -05:00
parent 78e2541ca1
commit e298a89eb8
2 changed files with 13 additions and 8 deletions

View File

@ -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:

View File

@ -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 "<a href='"+request_auth_url+"'>Login with Eagle Eye Networks</a>"
@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 "<a href='"+request_auth_url+"'>Login with Eagle Eye Networks</a>"
if __name__ == '__main__':