django - How to handle external API tokens after logout
问题描述
This is a higher level conceptual question. I use token authentication on my django - react app and I handle the token by saving, retrieving it, and removing it from local storage as necessary. The flow is sort of like this:
- user registers- generate token and save it to local storage
- user logs in - same thing
- user logs out - token is destroyed and removed from local storage
The external API I use also uses token authentication, however I would like to treat it differently as to enhance the user experience. I do not want (aka it is not correct) to generate a new token for the external api every time the user logs in. Upon logging in I would like to retrieve the previously generated token from somewhere, preferably local storage. Saving a token like this in local storage when the user is not logged in is also bad practice. Where is a good place to save this token? Right away I think my django server. However, I feel like it is overkill to generate a whole model for it, or even to create a new attribute for my user, since I would have to create a custom user model (I am using the built-in user model from Django). So...thoughts?
解决方案
推荐阅读
- c# - 在 XMLDocument 中将所有标记名称更改为小写
- docker - docker 工作需要在 Bios 中启用 Hyper-v
- angular - 在 Apache 中部署 Angular Universal
- python - 整数除法未产生预期结果
- python - 如何在 Python 中显示汉字?
- git - gitlab-runner 克隆代码失败,请求的 URL 返回错误:500
- php - Woocommerce 相关产品的属性,图片中缺少产品链接
- winapi - 为什么当父窗口处于全屏模式时子窗口不显示?
- php - 验证和验证
- cdi - 启用 CDI 时在 log4j2 的依赖项上遇到 UnsupportedClassVersionError