- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 django 的 rest_framework 库为 django 应用程序构建 API。一切都很顺利,我可以按预期通过 curl 命令访问我的 API。
现在,我想使用 CoreAPI 以客户端库的形式使事情变得更加优雅。
我能够进行如下基本身份验证:
auth = coreapi.auth.BasicAuthentication(username=user, password=password)
client = coreapi.Client(auth=auth)
token = 'Token abc12345'
#tried the following:
#token = 'abc12345'
#token = 'Authorization: Token abc12345'
auth = coreapi.auth.TokenAuthentication(token=token)
client = coreapi.Client(auth=auth)
coreapi.exceptions.ErrorMessage: <Error: 401 UNAUTHORIZED>
detail: "Authentication credentials were not provided."
最佳答案
我只是遇到了同样的问题。修复方法是为 coreapi.auth.TokenAuthentication 设置一个“scheme='Token'”参数。所以,这样的事情可能对你有用:
token = 'abc12345' # don't put the word 'Token' in front.
auth = coreapi.auth.TokenAuthentication(scheme='Token', token=token)
client = coreapi.Client(auth=auth)
关于django-rest-framework - 在 CoreAPI 中使用 TokenAuthentication 时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43642702/
我正在构建 Django Rest Framework 并想使用 coreapi 库测试 API。我可以在 python 脚本中以编程方式使用 coreapi 创建一个对象,但在命令行中,我无法创建相
我正在将 DropBox 集成到我的程序中,但是下载所有文件夹、子文件夹以及所有文件夹中的文件变得很麻烦。我知道如何列出根目录中的所有文件夹和文件,并使用以下代码单独下载每个文件夹和文件: DbxEn
所以我安装了 django-rest-swagger,如 django rest documentation 所示. 继续 from django.conf.urls import url from
我想使用 Python Client Library ,但是让 PUT/PATCH 工作没有尽头。每当我尝试使用 update/partial_update 时,URL 参数都不是从字典中插入的,并且
我正在使用 django 的 rest_framework 库为 django 应用程序构建 API。一切都很顺利,我可以按预期通过 curl 命令访问我的 API。 现在,我想使用 CoreAPI
我已经将 django rest 框架版本 3.10 集成到现有的 django 2.2 项目中,将 api root 放在 /api 。 现在我正在尝试使用 coreapi cli 客户端将一些文档
是否可以在具有 FileField 的模型中使用 HyperlinkedModelSerializer 将文件上传到 DRF? 我正在使用 utils 包中的 coreapi File 类,并且 co
我实际上被困在这个问题上几个小时了.. 我的代码很简单,只想使用标签索引添加几个节点。如果没有索引内容(不要创建 createDeferredSchemaIndex ),代码可以正常工作。 我的异常(
我是一名优秀的程序员,十分优秀!