omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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

    Pythonista
    4
    5
    3529
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • echen
      echen last edited by

      Is it possible to pass a username password to http Basic Auth in ui.webview? thx.

      1 Reply Last reply Reply Quote 0
      • ccc
        ccc last edited by

        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()
        
        1 Reply Last reply Reply Quote 1
        • JonB
          JonB last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • omz
            omz last edited by

            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()
            
            1 Reply Last reply Reply Quote 2
            • echen
              echen last edited by

              Thanks for the replies, both suggestions worked.

              1 Reply Last reply Reply Quote 1
              • First post
                Last post
              Powered by NodeBB Forums | Contributors