Python3 requests with authentication

Python October 17, 2018 python

Python3 requests with authentication

python
def get_data(auth_user, auth_passwd, url):
    headers = {'Accept': 'application/json'}
    response = requests.get(
        url, auth=requests.auth.HTTPBasicAuth(
            auth_user, auth_passwd), headers=headers)
    return json.loads(response.text)