2012-05-10 145 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授權的解決方法