'''
Basic Authentication
from requests.auth import HTTPBasicAuth
r1 = requests.get("https://httpbin.org/basic-auth/user/passwd",auth=HTTPBasicAuth("user","passwd"))
Digest Authentication
from requests.auth import HTTPDigestAuth
r2 = requests.get("https://httpbin.org/digest-auth/auth/user/passwd/MD5/never",auth=HTTPDigestAuth("user","passwd"))
Oauth Authentication
headers = {"Authorization":"token xxxxx"}
r3 = requests.get(url,headers=headers)
证书验证
requests.get("https://github.com",verify=True)#SSL证书
requests.get("https://kennethreitz",cert=("/path/server.crt","/path/key"))#客户端验证
自定义身份验证---requests.auth.AuthBase的自雷实现
requests.get("http://pizzabin.org/admin",auth=PizzAuth("kenneth"))
'''
import requests
#方法一:basic
r = requests.get("https://httpbin.org/basic-auth/user/passwd",auth=("user","passwd"))
print(r.text)
#方法二:
from requests.auth import HTTPBasicAuth
r1 = requests.get("https://httpbin.org/basic-auth/user/passwd",auth=HTTPBasicAuth("user","passwd"))
print(r1.text)
#方法三:Digest
from requests.auth import HTTPDigestAuth
r2 = requests.get("https://httpbin.org/digest-auth/auth/user/passwd/MD5/never",auth=HTTPDigestAuth("user","passwd"))
print(r2.text)
#Oanth授权--token
headers = {"Authorization":"token xxxxx"}
r3 = requests.get(url,headers=headers)