#!/usr/bin/env python3
import requests
from requests.auth import HTTPDigestAuth
from getpass import getpass

user=input("Podaj nazwę użytkownika: ")
password = getpass()
url = 'http://httpbin.org/digest-auth/auth/user/pass'
response = requests.get(url, auth = HTTPDigestAuth(user, password))
print("Nagłówki żądania:")
for header, value in response.request.headers.items():
    print(header, '-->', value)
print('Kod stanu: ' + str(response.status_code))
if response.status_code == 200:
    print('Uwierzytelnienie pomyślne: ' + str(response.json()))
    print("Nagłówki odpowiedzi:")
    for header, value in response.headers.items():
        print(header, '-->', value)