Program to do basic authentication using “requests” module in python

#!/usr/bin/env python3

import requests
from requests.auth import HTTPBasicAuth

requests.get('', auth=HTTPBasicAuth('user', 'password'))

# requests provides a shorthand for this authentication method
response = requests.get('', auth=('user', 'password'))

print('Response.status_code:'+ str(response.status_code))

if response.status_code == 200:
	print('Login successful :'+response.text)


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: