waiting for the new redirect_urls to be approved
parent
78e2541ca1
commit
e298a89eb8
|
@ -57,7 +57,7 @@ class EagleEyev3():
|
||||||
|
|
||||||
# Combine server_protocol, server_host, and server_port to make the redirect_uri
|
# 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
|
# 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):
|
def _save_access_token(self):
|
||||||
with open(".lazy_login", "w") as json_file:
|
with open(".lazy_login", "w") as json_file:
|
||||||
|
|
19
server.py
19
server.py
|
@ -12,17 +12,22 @@ def index():
|
||||||
# This is getting the ?code= querystring value from the HTTP request.
|
# This is getting the ?code= querystring value from the HTTP request.
|
||||||
code = request.args.get('code')
|
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):
|
if (code):
|
||||||
oauth_object = een.login_tokens(code)
|
oauth_object = een.login_tokens(code)
|
||||||
return f"Hello {een.current_user['firstName']} {een.current_user['lastName']}"
|
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__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in New Issue