wkaisertexas / tiktok-uploader

Automatically ⬆️ upload TikTok videos
https://pypi.org/project/tiktok-uploader/
MIT License
390 stars 91 forks source link

eror #7

Closed qweaeqew closed 1 year ago

qweaeqew commented 1 year ago

Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "C:\Users\Danil\AppData\Local\Programs\Python\Python311\Scripts\tiktok-uploader.exe\__main__.py", line 7, in <module> File "C:\Users\Danil\tiktok-uploader\src\tiktok_uploader\cli.py", line 20, in main result = upload_video( ^^^^^^^^^^^^^ File "C:\Users\Danil\tiktok-uploader\src\tiktok_uploader\upload.py", line 40, in upload_video auth = AuthBackend(username=username, password=password, cookies=cookies) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Danil\tiktok-uploader\src\tiktok_uploader\auth.py", line 39, in __init__ raise InsufficientAuth() tiktok_uploader.auth.InsufficientAuth how to fix it?

wkaisertexas commented 1 year ago

InsufficientAuth gets raised when your browser goes to tiktok.com/upload and gets redirected to the sign in page because you have not provided your browser cookies which is used to fake TikTok into thinking that you are logged in.

This is the method where this error was raised. You need to pass a cookies_list otherwise the browser has no way of knowing that you are logged in.

def __init__(self, username: str = '', password: str = '',
                 cookies_list: list = None, cookies=None):
        """
        Creates the authenticaiton backend
        Keyword arguments:
        - username -> the accounts's username or email
        - password -> the account's password
        - cookies -> a list of cookie dictionaries of cookies which is Selenium-compatable
        """
        if (username and not password) or (password and not username):
            raise InsufficientAuth()

        self.cookies = self.get_cookies(path=cookies) if cookies else []
        self.cookies += cookies_list if cookies_list else []

        if not (self.cookies or (username and password)):
            raise InsufficientAuth()  # error raised here

        self.username = username
        self.password = password

An important thing to note is that even though you may be logged into your browser, when the automated program takes control of your browser, it does not have your cookies and does not know that it is your browser. Consequently, you have to reprove that you are who you say you are to TikTok and the easiest way to do this is just copying your cookies over from a browser which is already logged in

wkaisertexas commented 1 year ago

Hey, in the new release, insufficient auth gives a much more through error description. Thank you for bringing this to my attention