2 Transitional code: bridge between Piston's OAuth implementation
5 from piston.authentication import OAuthAuthentication
6 from rest_framework.authentication import BaseAuthentication
9 class PistonOAuthAuthentication(BaseAuthentication):
11 self.piston_auth = OAuthAuthentication()
13 def authenticate_header(self, request):
14 return 'OAuth realm="API"'
16 def authenticate(self, request):
17 if self.piston_auth.is_valid_request(request):
18 consumer, token, parameters = self.piston_auth.validate_token(request)
19 if consumer and token:
20 return token.user, token