wkaisertexas / tiktok-uploader

Automatically ⬆️ upload TikTok videos
https://pypi.org/project/tiktok-uploader/
360 stars 84 forks source link

The issue of configuring proxy for Firefox #143

Closed tonysmiles closed 4 months ago

tonysmiles commented 4 months ago

I want to add additional Firefox configuration with a proxy. However, after running, I encountered an issue: the user authentication dialog always appears when the browser is opened, even though I have provided the username and password.

Below is the code where I applied a proxy extension to each profile, which works fine. However, I don't want to use an extension because it's time-consuming to configure. Does anyone have any ideas on configuring a proxy in Firefox without being prompted for username and password? Let's discuss!

Create a new FirefoxProfile

profile = FirefoxProfile(profile_directory=r"C:\Users\tuanm\AppData\Roaming\Mozilla\Firefox\Profiles\kfdh8b7s.demo")

# Add extension to the profile
profile.add_extension(extension=r"C:\Users\tuanm\AppData\Roaming\Mozilla\Firefox\Profiles\kfdh8b7s.demo\extensions\switchyomega@feliscatus.addons.mozilla.org.xpi")

# Set proxy configuration if provided
if proxy:
    proxy_host = proxy.get('host')
    proxy_port = proxy.get('port')

    if proxy_host and proxy_port:
        profile.set_preference("network.proxy.type", 1)
        profile.set_preference("network.proxy.http", proxy_host)
        profile.set_preference("network.proxy.http_port", int(proxy_port))
        profile.set_preference("network.proxy.ssl", proxy_host)
        profile.set_preference("network.proxy.ssl_port", int(proxy_port))
        profile.set_preference("network.proxy.socks", proxy_host)
        profile.set_preference("network.proxy.socks_port", int(proxy_port))

# Create FirefoxOptions and set the profile
options = FirefoxOptions()
options.profile = profile

# Set headless mode if specified
if headless:
    options.headless = True

return options
Lamaizi199 commented 4 months ago

switchyomega@feliscatus.addons.mozilla.org.xpi

wkaisertexas commented 4 months ago

I think what is happening is your authentication state is tied, in part, to the network used to login. The proxy could be deemed sufficiently different from the browser used to login to TikTok which could cause issues.

tonysmiles commented 4 months ago

I think what is happening is your authentication state is tied, in part, to the network used to login. The proxy could be deemed sufficiently different from the browser used to login to TikTok which could cause issues.

I configured the proxy manually and used the profile to do the upload and it solved that problem, however the problem then was that the video was hidden even though I received a notification that the video was successfully posted.