2012-05-10 144 views
2

我现在非常熟悉tastypie,它与授权和身份验证密切相关。django tastypie自定义登录

有没有办法从另一个位置的页面登录可以用于授权,而不是有美味的饼图验证弹出?

当用户提出登录请求时,如果他们没有使用浏览器,而是使用本机应用程序,他们的移动设备上将如何显示该弹出窗口。

跟它401未授权

我尝试的示例代码下面

class MyAuthentication(BasicAuthentication): 
    def is_authenticated(self, request, **kwargs): 
     from django.contrib.auth import authenticate 
     #for now i tried static but still not working are return types correct  
     def is_authenticated(self, request, **kwargs): 
      from django.contrib.auth import authenticate 
      user = authenticate(username='admin', password='admin') 

      if user is not None: 
       if user.is_active: 
        return True 
       else: 
       return self._unauthorized() 
      else: 
       return self._unauthorized() 




class EntryResource(ModelResource): 
    class Meta: 
     queryset = Entry.objects.all() 
     resource_name = 'entry' 
     #authorization = Authorization() 
     authorization = DjangoAuthorization() 
     authentication = MyAuthentication() 

    filtering = { 
     'user': ALL_WITH_RELATIONS, 
     'pub_date': ['exact', 'lt', 'lte', 'gte', 'gt'], 
     } 

回答

1

在Django的tastypie官方的文档,他们说从来没有使用授权生产部署,所以必须与djangoa授权的解决方法