Created
September 7, 2012 15:36
-
-
Save lovelydinosaur/3667231 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class GetAccessToken(APIView): | |
| authentication_classes = [authentication.UserBasicAuthentication] | |
| permission_classes = [permissions.UserIsAuthenticated] | |
| model = djangorestframework.basictoken.models.BasicToken | |
| def post(self, request, *args, **kwargs): | |
| token = self.model.objects.get_or_create(user=request.user) | |
| return Response({'key': token.key}) |
Author
Author
Ooops, that didn't quite work.
If a user has more than one key, how would the view know which to choose?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
class GetAccessToken(APIView):
authentication_classes = [authentication.UserBasicAuthentication]
permission_classes = [permissions.UserIsAuthenticated]
model = djangorestframework.basictoken.models.BasicToken