简体   繁体   English

如何使用 Fastapi 创建一个 session,这样当用户登录时,我们可以将它的 ID 用于多种用途。 我的意思是我们只能从 session 获取 id

[英]How to create a session using Fastapi so when a user login we can use it's id for multipurpose. I mean we can fetch id from session only

I want to create a session in fast API to get data from cookies.我想在快速 API 中创建一个 session 以从 cookies 获取数据。

API stops being API when you use sessions.当您使用会话时,API 不再是 API。 You can use JWT authentication in this case, not session. Otherwise you'd best build websocket architecture.在这种情况下,您可以使用 JWT 身份验证,而不是 session。否则,您最好构建 websocket 架构。 See official FastAPI docs https://fastapi.tiangolo.com/advanced/websockets/参见官方 FastAPI 文档https://fastapi.tiangolo.com/advanced/websockets/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 pytest-django 每个 session 只创建一次用户 object? - How can I use pytest-django to create a user object only once per session? 我们如何使用python和html设置会话? - how can we set session using python and html? 我如何使用用户 ID 将其与条件匹配,以便当用户向频道发送消息时,机器人可以为用户执行特定任务 - how do i use user's ID for matching it with a condition so that when the user sends message to channel, the bot can do specific tasks for the user 注销后如何保存购物车数据的session,以便用户在Django中再次登录时可以找到它们? - How can save session of shopping cart data after logout, so the user can find them when login again in Django? 无法使用 FastAPI 中的 SessionMiddleware 从 session 获取变量 - Can't get variable from session using SessionMiddleware in FastAPI 我们如何在Open CV中创建跟踪栏,以便可以使用它跳到视频的特定部分? - How do we create a trackbar in Open CV so that I can use it to skip to specific section of the video? 我可以通过 django 创建 session 登录吗? - Can I create a session login by django? 我们如何使用 div id 访问 div 元素文本 - how can we access div element text using div id 我怎样才能获取到 fastapi - how can i fetch to fastapi 这个给定的文本是 json 格式。因为我是 python 的新手,所以告诉我如何只从用户那里获取 id - This given text is in json format.As i am new to python so tell me how can i get id from user only
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM