Python Glossary Русский

all Python 3urllib.requestterm

urllib.request.HTTPPasswordMgrWithDefaultRealm

authentication

A password store where realm=None means any realm — the usual choice when you do not know the server's realm name.

Syntax

mgr = urllib.request.HTTPPasswordMgrWithDefaultRealm(); mgr.add_password(None, uri, user, passwd)

The password is looked up for the exact realm first and then for None, so one None entry covers every realm of the site. The address may omit the scheme: 'example.com' matches any path on that host. It sends nothing by itself — pass it to HTTPBasicAuthHandler or HTTPDigestAuthHandler.

Examples

import urllib.request
mgr = urllib.request.HTTPPasswordMgrWithDefaultRealm()
mgr.add_password(None, 'example.com', 'user', 'secret')
print(mgr.find_user_password('any realm', 'http://example.com/x'))  # → ('user', 'secret')

See also

Open in the full glossarydocs.python.orgReport an inaccuracy