From ab2db14bc8ddacf9bac2499c1d5924d87181573d Mon Sep 17 00:00:00 2001 From: Kevin Fronczak Date: Sat, 13 Feb 2021 11:33:05 -0500 Subject: [PATCH] Add reauth param back into login...may stop emails - Also added a debug script because I'm tired of typing the same commands over and over again when debugging --- .gitignore | 1 + blinkpy/api.py | 1 + blinkpy/helpers/constants.py | 2 +- debug_login.py | 77 ++++++++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 debug_login.py diff --git a/.gitignore b/.gitignore index 5eabca9..ebe0e92 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ build/* docs/_build *.log venv +.session* diff --git a/blinkpy/api.py b/blinkpy/api.py index 0d77646..3df449a 100644 --- a/blinkpy/api.py +++ b/blinkpy/api.py @@ -32,6 +32,7 @@ def request_login( "unique_id": login_data["uid"], "device_identifier": login_data["device_id"], "client_name": "Computer", + "reauth": True, } ) diff --git a/blinkpy/helpers/constants.py b/blinkpy/helpers/constants.py index a1b3592..d6660a3 100644 --- a/blinkpy/helpers/constants.py +++ b/blinkpy/helpers/constants.py @@ -4,7 +4,7 @@ import os MAJOR_VERSION = 0 MINOR_VERSION = 17 -PATCH_VERSION = "0.rc0" +PATCH_VERSION = "0.rc1" __version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}.{PATCH_VERSION}" diff --git a/debug_login.py b/debug_login.py new file mode 100644 index 0000000..15d8955 --- /dev/null +++ b/debug_login.py @@ -0,0 +1,77 @@ +"""Login testing script.""" +import sys +import os +from blinkpy.blinkpy import Blink +from blinkpy.auth import Auth +from blinkpy.helpers.util import json_load, json_save + +save_session = False +print("") +print("Blink Login Debug Script ...") +print(" ... Loading previous session information.") +cwd = os.getcwd() +print(f" ... Looking in {cwd}.") +session_path = os.path.join(cwd, ".session_debug") +session = json_load(session_path) + +try: + auth_file = session["file"] +except (TypeError, KeyError): + print(" ... Please input location of auth file") + auth_file = input(" Must contain username and password: ") + save_session = True + +data = json_load(auth_file) +if data is None: + print(f" ... Please fix file contents of {auth_file}.") + print(" ... Exiting.") + sys.exit(1) + +try: + username = data["username"] + password = data["password"] +except KeyError: + print(f" ... File contents of {auth_file} incorrect.") + print(" ... Require username and password at minimum.") + print(" ... Exiting.") + sys.exit(1) + +if save_session: + print(f" ... Saving session file to {session_path}.") + json_save({"file": auth_file}, session_path) + +blink = Blink() +auth = Auth(data) +blink.auth = auth + +print(" ... Starting Blink.") +print("") +blink.start() +print("") +print(" ... Printing login response.") +print("") +print(blink.auth.login_response) +print("") +print(" ... Printing login attributes.") +print("") +print(blink.auth.login_attributes) +print("") +input(" ... Press any key to continue: ") +print(" ... Deactivating auth token.") +blink.auth.token = "foobar" +print(f"\t - blink.auth.token = {blink.auth.token}") + +print(" ... Attempting login.") +print("") +blink.start() +print("") +print(" ... Printing login response.") +print("") +print(blink.auth.login_response) +print("") +print(" ... Printing login attributes.") +print("") +print(blink.auth.login_attributes) +print("") +rint(" ... Done.") +print("")