django-piston-two-legged-oauth is a simple 2-legged OAuth connector for Django Piston.
- django piston 2-legged OAuth authentication discussion
- Beginner’s Guide to OAuth – Part II : Protocol Workflow
# urls.py
from api.authentication import TwoLeggedOAuthAuthentication
from api.handlers import DoSomethingHandler
two_legged_oauth = TwoLeggedOAuthAuthentication(realm='API')
class CsrfExemptResource( Resource ):
def __init__( self, handler, authentication = None ):
super( CsrfExemptResource, self ).__init__( handler, authentication )
self.csrf_exempt = getattr( self.handler, 'csrf_exempt', True )
def TwoLeggedOAuthProtectedResource(handler):
return CsrfExemptResource(handler=handler, authentication=two_legged_oauth)
do_something = TwoLeggedOAuthProtectedResource( DoSomethingHandler )
urlpatterns = patterns('',
url( r'^do_something', do_something, name='do_something'),
)