python - 为什么我不能在 FastApi swagger ui 中授权 api 调用,其中可以使用 postman 授权和调用相同的 api?
问题描述
我开始用 FastApi 编程。它带有一个内置的 swagger 接口,可以与我的代码中的 api 进行交互。我已经完成了数据库中用户的身份验证和授权。但是 swagger 并没有授权我的数据库中的用户使用邮递员获得授权。swagger ui 授权表单显示“用户名”和“密码”,我的表将“电话号码”作为唯一字段。
模型.py
from sqlalchemy import Column, String, BigInteger, Integer from utils.database import Base
类 UserModel(Base): tablename = "user"
id = Column(BigInteger, primary_key=True, index=True)
phoneNumber = Column(Integer, unique=True, index=True)
password = Column(String, index=True)
type = Column(String, index=True)
解决方案
推荐阅读
- python - 使用转换器提升 Python 问题 - 静态链接
- cassandra - 将 Janusgraph 从 0.2.2 升级到 0.5.2
- html - 垂直对齐 mat-checkbox 和 mat-form-field | 角材料 | 角
- azure-cosmosdb - 是否建议在 cosmosdb 中有大量的逻辑分区
- linux - 如何通过shell脚本向csv文件的第一列添加值
- ruby - 从标准输入加载 gemspec
- python-3.x - 如果我使用动作属性,Django 表单不会保存
- c - 在scanf中读取字符'-'
- asp.net-core - AddWebhookNotification 调用Controller中的方法
- html - 使用 Crispy Forms 渲染 django 的 Multiwidget 和 MutliValueField 文本区域