【发布时间】:2017-04-20 14:07:12
【问题描述】:
当我通过 ios 调用 oscarapi 调用时,我遇到了一个奇怪的问题。它与邮递员一起工作正常。但是当我通过 xcode 调用时,它显示以下错误。
HTTP/1.1 401 Authorization Required
Connection: Keep-Alive
Content-Type: application/json
Server: Apache/2.4.7 (Ubuntu)
Allow: GET, HEAD, OPTIONS
Vary: Accept,Authorization,Cookie
Date: Thu, 20 Apr 2017 13:55:13 GMT
X-Frame-Options: SAMEORIGIN
Www-Authenticate: Bearer realm="api"
Keep-Alive: timeout=5, max=100
Transfer-Encoding: Identity
{"detail":"Authentication credentials were not provided."}
我发送标题授权如下。这在邮递员中工作正常。
Authorization: Bearer iw7cGIz4uF036j7VbpGCXbceCCbbD1
我的 urls.py
url(r'^api/v1/categories', views.CategoryListCustom.as_view(), name='category-list')
views.py
class CategoryListCustomd(generics.ListAPIView):
def get_queryset(self):
queryset = Category.objects.all()
return queryset
serializer_class = CustomCategorySerializer
【问题讨论】:
标签: django django-rest-framework django-authentication django-oscar