123456789101112131415161718192021222324252627282930 |
- import requests
- # --- test 获取token ---
- service_url = 'http://10.10.61.229:9000'
- url = f'{service_url}/token/api'
- data = {
- 'username': 'admin',
- 'password': 'admin',
- }
- response = requests.post(url=url, json=data)
- print(response.headers)
- """
- {
- 'date': 'Thu, 04 Jan 2024 07:19:58 GMT',
- 'server': 'uvicorn',
- # 登录token
- 'authorization': 'eyJhbGciOiJIUzUxMiIsImlhdCI6MTcwNDM1Mjc5OCwiZXhwIjoxNzA0NDM5MTk4fQ.eyJpZCI6IjY1NGUzNmI0NjBmZGE0M2UzOTI2YzNmYiIsInVzZXJuYW1lIjoiYWRtaW4iLCJwYXNzd29yZCI6InBia2RmMjpzaGEyNTY6MTUwMDAwJGxEN1duR0hxJGUyNjhhNzgxOTFhYjdiNDE2ZDcxZjE1MDkxNzJjZWVkZWI3ZTNmNTM1ZGY0MGQ5NmQ4MzZlYmRjNTFmZGRmMzkifQ.IGi0lXezecP5AEjxgQ4lzQ5jyeYwDLoGmD7n29Q_1X6faSo4EKj4Q8A89BiAKBhjGAiNe7FSBFjmqhoZEXacUg',
- 'content-length': '107',
- 'content-type': 'application/json'
- }
- """
- print(response.json())
- """
- {
- 'code': 0 # 错误码 {0: 无异常}
- 'message': 'authorization passed.',
- 'uid': '654e36b460fda43e3926c3fb', # 登录用户id
- 'role_name': '超级管理员',
- }
- """
|