Token authentication
Some logins use cookie and some logins require token authentication.
Generally speaking, there are two forms of passing parameters in token, one is in the request header, and the other is using URL to pass parameters.
Here is an example to illustrate the token mode in the request header:
# Login
Param1= {'username':'xxx','password':'xxxx'}
R1=requests.post ('http://127.0.0.1:12306/login',data=param1)
Print (r1.text)
Print (r1.status_code)
# obtain token after login
Dic1=json.loads (r1.text) or direct dict1=r1.json ()
Token1=dic1 ['token']
Print (token1)
# token is added to the request header to visit
Header= {'Authorization':'Bearer' + token1}
R2=requests.get ('http://127.0.0.1:12306/api/tasks',headers=header)