Ejemplo n.º 1
0
def initialize_oauth(request):
    oauth_request = OAuthRequest.from_request(
        request.method, request.url, headers=request.headers, query_string=urllib.urlencode(request.values)
    )
    oauth_server = OAuthServer(OAuthDataStore())
    oauth_server.add_signature_method(OAuthSignatureMethod_PLAINTEXT())
    oauth_server.add_signature_method(OAuthSignatureMethod_HMAC_SHA1())
    return [oauth_request, oauth_server]
Ejemplo n.º 2
0
    def inner(request, *args, **kwargs):
        try:
            oauth_request = OAuthRequest.from_request(request.method,
                    request.url, headers=request.headers,
                    query_string=urllib.urlencode(request.values))
            oauth_server = OAuthServer(OAuthDataStore())
            oauth_server.add_signature_method(OAuthSignatureMethod_PLAINTEXT())
            oauth_server.add_signature_method(OAuthSignatureMethod_HMAC_SHA1())

            consumer, token, params = oauth_server.verify_request(oauth_request)
            request.consumer = consumer
            request.token = token
            request.oauth_params = params
            return func(request, *args, **kwargs)
        except OAuthError, e:
            logging.debug(e)
            logging.debug(e.message)
            return BadRequest("%s" % e.message)