(PostMan) token未知时进行接口调试的解决方案

本文介绍如何使用PostMan进行接口调试,特别是当token未知时的解决方案。通过添加Cookie的方式解决前端页面接口调试的问题,具体步骤包括在PostMan中添加Cookie、在谷歌浏览器中通过F12调试台获取token值。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

(PostMan)token未知时进行接口调试的解决方案

  1. 打开PostMan,点击cookie在这里插入图片描述

  2. 然后我们ADD一个Cookie在这里插入图片描述

  3. 找到cookie在PostMan中的对应位置在这里插入图片描述

  4. 进入前端页面随机点开一个成型接口,F12打开调试台(google浏览器),在菜单栏寻找Network栏,点击localhost左侧栏,之后点开headers查找cookie的值在这里插入图片描述

  5. 5、图片中Esp-Token是token的种类,=之后是token的值,在这里插入图片描述

  6. 最后在postMan中加入cookie值:在这里插入图片描述

C:\Users\Administrator\anaconda3\python.exe "E:/pycharm/PyCharm 2024.2.4/plugins/python-ce/helpers/pydev/pydevconsole.py" --mode=client --host=127.0.0.1 --port=51678 import sys; print('Python %s on %s' % (sys.version, sys.platform)) sys.path.extend(['C:\\Users\\Administrator\\PycharmProjects\\scientificProject']) PyDev console: using IPython 8.15.0 Python 3.11.5 | packaged by Anaconda, Inc. | (main, Sep 11 2023, 13:26:23) [MSC v.1916 64 bit (AMD64)] on win32 runfile('C:\\Users\\Administrator\\PycharmProjects\\scientificProject\\travel.py', wdir='C:\\Users\\Administrator\\PycharmProjects\\scientificProject') 请输入目标城市:>? 广州 请输入出行日期(YYYY-MM-DD):>? 2025-03-25 【天气预报】 [调试] 地理API响应: {'error': {'status': 401, 'type': 'https://dev.qweather.com/docs/resource/error-code/#unauthorized', 'title': 'Unauthorized', 'detail': 'Authentication failed, check your KEY/Token or Host.'}} ❌ 接口错误:未知错误 【旅游攻略】 Traceback (most recent call last): File "C:\Users\Administrator\anaconda3\Lib\site-packages\IPython\core\interactiveshell.py", line 3526, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "<ipython-input-2-4805391bd2fc>", line 1, in <module> runfile('C:\\Users\\Administrator\\PycharmProjects\\scientificProject\\travel.py', wdir='C:\\Users\\Administrator\\PycharmProjects\\scientificProject') File "E:\pycharm\PyCharm 2024.2.4\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_umd.py", line 197, in runfile pydev_imports.execfile(filename, global_vars, local_vars) # execute the script ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "E:\pycharm\PyCharm 2024.2.4\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "C:\Users\Administrator\PycharmProjects\scientificProject\travel.py", line 78, in <module> guide = planner.generate_guide(city) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Administrator\PycharmProjects\scientificProject\travel.py", line 51, in generate_guide client = Deepseek(api_key=self.deepseek_key) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Administrator\PycharmProjects\scientificProject\deepseek_api.py", line 10, in __init__ response = client.chat.completions.create( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Administrator\anaconda3\Lib\site-packages\openai\_utils\_utils.py", line 279, in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Administrator\anaconda3\Lib\site-packages\openai\resources\chat\completions\completions.py", line 914, in create return self._post( ^^^^^^^^^^^ File "C:\Users\Administrator\anaconda3\Lib\site-packages\openai\_base_client.py", line 1242, in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Administrator\anaconda3\Lib\site-packages\openai\_base_client.py", line 919, in request return self._request( ^^^^^^^^^^^^^^ File "C:\Users\Administrator\anaconda3\Lib\site-packages\openai\_base_client.py", line 1023, in _request raise self._make_status_error_from_response(err.response) from None openai.AuthenticationError: Error code: 401 - {'error': {'message': 'Authentication Fails (no such user)', 'type': 'authentication_error', 'param': None, 'code': 'invalid_request_error'}}
03-19
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值