运行结果:
代码:
class TestLoginApi:
access_token = ""
session = requests.session() # 通过session去关联
def test_get_token(self):
print("获取token鉴权码")
url = "http://192.168.2.79:1189/api/login/login/phone"
header = {
"content-typy": "application/json"
}
data = {
"loginWay": 0, # 登录方式 0=验证码 1=手机号密码登录
"phone": "15984016669", # 手机号
"code": "", # 密码/验证码
"invitationCode": "" # 邀请Code 没有则不填
}
res = TestLoginApi.session.request("post",url=url,json=data ,headers=header)
TestLoginApi.access_token = res.json()["data"]["token"]
print(TestLoginApi.access_token)
标签:json,TestLoginApi,接口,access,token,session,鉴权码 From: https://www.cnblogs.com/mmds/p/17167358.html