Skip to content

Another way to automate 2FA #6

@graymatter001

Description

@graymatter001
@@ -236,19 +236,8 @@ class Session(requests.Session):
         # 自动获取 2FA code

         if self._config["auto"]:
-            # 不断尝试获取 code.txt 内容,如果为空则等待 1s
-            code = ""
-            for i in range(30):
-                with open("code.txt", "r") as f:
-                    code = f.read().strip()
-                if code:
-                    break
-                print("Waiting for code...")
-                time.sleep(1)
-            # 删除 code.txt
-            with open("code.txt", "w") as f:
-                f.write("")
-
+            totp = pyotp.TOTP(self._config["totp"])
+            code = totp.now()
         # 手动输入 2FA code
         else:
             code = input("Please input the 2FA code: ")

:)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions