Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
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
requests
to 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
requests
and 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:passwd@httpbin.org/basic-auth/user/passwd') v.present()
-
Thanks for the replies, both suggestions worked.