test_token.py 998 B

123456789101112131415161718192021222324252627282930
  1. import requests
  2. # --- test 获取token ---
  3. service_url = 'http://10.10.61.229:9000'
  4. url = f'{service_url}/token/api'
  5. data = {
  6. 'username': 'admin',
  7. 'password': 'admin',
  8. }
  9. response = requests.post(url=url, json=data)
  10. print(response.headers)
  11. """
  12. {
  13. 'date': 'Thu, 04 Jan 2024 07:19:58 GMT',
  14. 'server': 'uvicorn',
  15. # 登录token
  16. 'authorization': 'eyJhbGciOiJIUzUxMiIsImlhdCI6MTcwNDM1Mjc5OCwiZXhwIjoxNzA0NDM5MTk4fQ.eyJpZCI6IjY1NGUzNmI0NjBmZGE0M2UzOTI2YzNmYiIsInVzZXJuYW1lIjoiYWRtaW4iLCJwYXNzd29yZCI6InBia2RmMjpzaGEyNTY6MTUwMDAwJGxEN1duR0hxJGUyNjhhNzgxOTFhYjdiNDE2ZDcxZjE1MDkxNzJjZWVkZWI3ZTNmNTM1ZGY0MGQ5NmQ4MzZlYmRjNTFmZGRmMzkifQ.IGi0lXezecP5AEjxgQ4lzQ5jyeYwDLoGmD7n29Q_1X6faSo4EKj4Q8A89BiAKBhjGAiNe7FSBFjmqhoZEXacUg',
  17. 'content-length': '107',
  18. 'content-type': 'application/json'
  19. }
  20. """
  21. print(response.json())
  22. """
  23. {
  24. 'code': 0 # 错误码 {0: 无异常}
  25. 'message': 'authorization passed.',
  26. 'uid': '654e36b460fda43e3926c3fb', # 登录用户id
  27. 'role_name': '超级管理员',
  28. }
  29. """