ui.webview and authentication
Is it possible to pass a username password to http Basic Auth in ui.webview? thx.
You could try using the
requeststo get past the login screen and then use a ui.WebView to display the resulting html. It usually requires some patient tinkering to get automated logins working correctly but requests does make it easier.
# coding: utf-8 import requests, ui def basic_login_webview(url, username, password): webview = ui.WebView(name=url) webview.load_html(requests.get(url, auth=(username, password)).text) return webview webview = basic_login_webview(url='https://my.favorite.url', username='xxx', password='yyy') webview.present()
this is likely possible in 2.0 using objc... Another option would be to use
requestsand then use load_html, and delegate methods, but that is somewhat annoying.
You should be able to pass the username and password as part of the URL, e.g.:
import ui v = ui.WebView() v.load_url('http://user:firstname.lastname@example.org/basic-auth/user/passwd') v.present()
Thanks for the replies, both suggestions worked.