GET 请求因有效访问令牌而失败
我在网站上有一个帐户:https://dev.yuride.network/
我将它用于测试目的。我遇到了一个特定的 API 问题
https://dev.yuride.network/api/users/me/< br> 我正在向上述 URL 发出 GET 请求并传递访问令牌,例如:response = requests.get(url, headers={'accesstoken': accessToken})
访问令牌是通过 API 调用
获取的 https://dev.yuride.network/api/token/?name=xyz< /a> 并使用
传递有效负载数据 用户名
和密码
此API已成功使用JSON返回访问令牌
{
"access":"asdsad",
"refresh":"asdasd"
}
,但请求requests.get(URL, headers={'accesstoken': accessToken})< /code> 失败
我不确定我是否以错误的方式传递标头,或者要使用的密钥应该是
与我使用的 accesstoken 不同,
我从检查选项卡复制了curl命令,同时从地址栏转到/api/user/me:
curl 'https://dev.yuride.network/api/users/me/' \
-H 'authority: dev.yuride.network' \
-H 'pragma: no-cache' \
-H 'cache-control: no-cache' \
-H 'sec-ch-ua: " Not A;Brand";v="99", "Chromium";v="99", "Microsoft Edge";v="99"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "Windows"' \
-H 'upgrade-insecure-requests: 1' \
-H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.74 Safari/537.36 Edg/99.0.1150.55' \
-H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9' \
-H 'sec-fetch-site: none' \
-H 'sec-fetch-mode: navigate' \
-H 'sec-fetch-user: ?1' \
-H 'sec-fetch-dest: document' \
-H 'accept-language: en-US,en;q=0.9' \
-H 'cookie: saml_session=aayrv7sksot1ooztihpht7svi5cydcet; csrftoken=6sQYPXR7ldqU5LCuR19DkUvsRbWmyll4TamiM4DqjKQdzWTh4u3TGkvI8ZwgGYbp; sessionid=5r6v6uk5vv3aufyt82np2guxn30pa3gu' \
--compressed
上面的命令在bash shell上运行良好。它没有任何访问令牌
I have an account on the website: https://dev.yuride.network/
I am using it for testing purposes. There is a particular API that I am getting issues with
https://dev.yuride.network/api/users/me/
I am making GET request to the above URL and passing the access token like:response = requests.get(url, headers={'accesstoken': accessToken})
The access token is obtained by making an API call to
https://dev.yuride.network/api/token/?name=xyz and passing payload data withusername
and password
this API is successfully returning the access token with JSON
{
"access":"asdsad",
"refresh":"asdasd"
}
But the request requests.get(URL, headers={'accesstoken': accessToken})
is failing
I am not sure if I am passing the header the wrong way or the key to be used should be
different than the accesstoken
that I am using
I copied the curl command from the inspect tab while going to /api/user/me from the address bar :
curl 'https://dev.yuride.network/api/users/me/' \
-H 'authority: dev.yuride.network' \
-H 'pragma: no-cache' \
-H 'cache-control: no-cache' \
-H 'sec-ch-ua: " Not A;Brand";v="99", "Chromium";v="99", "Microsoft Edge";v="99"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "Windows"' \
-H 'upgrade-insecure-requests: 1' \
-H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.74 Safari/537.36 Edg/99.0.1150.55' \
-H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9' \
-H 'sec-fetch-site: none' \
-H 'sec-fetch-mode: navigate' \
-H 'sec-fetch-user: ?1' \
-H 'sec-fetch-dest: document' \
-H 'accept-language: en-US,en;q=0.9' \
-H 'cookie: saml_session=aayrv7sksot1ooztihpht7svi5cydcet; csrftoken=6sQYPXR7ldqU5LCuR19DkUvsRbWmyll4TamiM4DqjKQdzWTh4u3TGkvI8ZwgGYbp; sessionid=5r6v6uk5vv3aufyt82np2guxn30pa3gu' \
--compressed
The above command runs fine on bash shell. It doesn't have any access token
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论