如何在 python 中与其他平台一起使用 cookie

How to use cookies in python with other platform

我的 python 应用程序允许人们在第三方平台上上传文件。

他们需要向我的服务器索取令牌,供平台验证

看起来像:

当人们上传文件时,他们 post 到平台

<form method="post" action="http://upload.qiniu.com/"
 enctype="multipart/form-data">
  <input name="key" type="hidden" value="<resource_key>">
  <input name="x:<custom_name>" type="hidden" value="<custom_value>">
  <input name="token" type="hidden" value="<upload_token>">
  <input name="file" type="file" />
  <input name="crc32" type="hidden" />
  <input name="accept" type="hidden" />
</form>

我想知道是否可以在每次有人尝试上传文件时请求令牌,或者只是让人们在登录时获取令牌,将令牌设置到 cookie 中并使其寿命与 cookie 的一样长? 谢谢

通常的做法是将客户端访问令牌存储为返回用户的 cookie。

This and also this 所以 post 也支持这个想法。