【发布时间】:2020-03-08 12:40:19
【问题描述】:
我正在尝试通过 bash 脚本使用 curl 来使用 curl -c cookies.txt https://www.mydjangoapp.com/ 存储 cookie,以便我可以在后续 curl 请求中使用 CSRF 令牌(在后续命令中使用 -b cookies.txt 选项)。
但是,当我运行cat cookies.txt 查看内容时,该文件只包含以下内容:
# Netscape HTTP Cookie File
# https://curl.haxx.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.
此外,当使用详细的-v 选项时,cookie 在响应中也不可见。
当我检查通过 Chrome 开发者工具返回的 cookie 时,我看到了所有我期望的 cookie。
我已验证在对其他端点运行 curl 命令时,cookies.txt 已填充 cookie。
对这可能如何发生有任何想法吗?特别是,我正在尝试获取 CSRF 令牌,但这似乎是 curl 和我的 Django 应用程序更普遍的 cookie 检索问题。
【问题讨论】:
标签: django curl cookies django-rest-framework