Setting proxy on Appium in options

I am using Appium Python Client to automate my MacOS Desktop app, and I want to configure the driver to a http and https proxy. How do I pass it in as options?

from appium import webdriver as appium_webdriver
from appium.options.mac import Mac2Options

options = Mac2Options()
options.bundle_id = BUNDLE_ID
options.proxy = {
    "proxyType": "manual",
    "httpProxy": PROXY_DOMAIN,
    "httpProxyPort": PROXY_PORT,
    "httpPassword": PROXY_PASSWORD,
    "httpUser": PROXY_USER,
}
driver = appium_webdriver.Remote(f"http://{APPIUM_HOST}:{APPIUM_PORT}", options=options)

I am receiving an error: selenium.common.exceptions.InvalidArgumentException: Message: Only Proxy objects can be passed in.

Next, I tried setting the proxy using Python’s subprocess module before starting the driver. It worked as I am receiving alerts shown below to use my proxy’s information after I start the driver.


The code for the above:

def set_proxy():
    subprocess.run(['networksetup', '-setwebproxy', 'Wi-fi', '10.49.85.215', '443', 'on', 'username', 'pw'])
    subprocess.run(['networksetup', '-setwebproxystate', 'Wi-fi', 'on'])

    subprocess.run(['networksetup', '-setsecurewebproxy', 'Wi-fi', '10.49.85.215', '443', 'on', 'username', 'pw'])
    subprocess.run(['networksetup', '-setsecurewebproxystate', 'Wi-fi', 'on'])

def check_proxy():
    web_proxy_status = subprocess.run(['networksetup', '-getwebproxy', 'Wi-fi'], capture_output=True, text=True)
    if 'Enabled: Yes' in web_proxy_status.stdout:
        print('Web proxy is enabled')
    else:
        print('Web proxy is not enabled')

    secure_web_proxy_status = subprocess.run(['networksetup', '-getsecurewebproxy', 'Wi-fi'], capture_output=True, text=True)
    if 'Enabled: Yes' in secure_web_proxy_status.stdout:
        print('Secure web proxy is enabled')
    else:
        print('Secure web proxy is not enabled')
 
set_proxy()
check_proxy()
driver = appium_webdriver.Remote(f"http://{APPIUM_HOST}:{APPIUM_PORT}", options=options)

How do I ensure that the Appium driver is granted permissions so these prompts do not appear?

Unfortunately Appium does not support proxies