def get_http_auth_credentials(qurl, authenticator, parent=None): qurl = QUrl(qurl) qurl.setFragment(None) realm = authenticator.realm() trealm = (' (%s)' % realm) if realm else '' ac = parent and parent.get_login_credentials(qurl.toString()) d = Credentials( _('Please specify a password for {0}{1}').format( qurl.toString(), trealm), parent) if ac is not None: if ac['autologin']: authenticator.setUser(ac['username']) authenticator.setPassword(ac['password']) return d.credentials = ac['username'], ac['password'] if d.exec() == QDialog.DialogCode.Accepted: username, password = d.credentials authenticator.setUser(username) authenticator.setPassword(password) if parent is not None: parent.on_login_form_submit(qurl.toString(), username, password) else: if parent is not None: parent.setHtml( '<p style="font-family:sans-serif">{} {}</p>'.format( _('Authentication required to access: '), '<a href="{0}">{0}</a>'.format(qurl.toDisplayString())))
def get_proxy_auth_credentials(qurl, authenticator, proxy_host, parent=None): qurl = QUrl(qurl) qurl.setFragment(None) d = Credentials( _('Please specify a password for {0} at the proxy: {1}').format( qurl.toString(), proxy_host), parent) if d.exec() == d.Accepted: username, password = d.credentials authenticator.setUser(username) authenticator.setPassword(password)