def verify_oauth_request(request, oauth_request, consumer, token=None):
 from treeio.core.api.auth.store import store
 if (not store.check_nonce(request, oauth_request, oauth_request['oauth_nonce'])):
  return False
 try:
  oauth_server = oauth.Server()
  oauth_server.add_signature_method(oauth.SignatureMethod_HMAC_SHA1())
  oauth_server.add_signature_method(oauth.SignatureMethod_PLAINTEXT())
  consumer = oauth.Consumer(consumer.key.encode('ascii', 'ignore'), consumer.secret.encode('ascii', 'ignore'))
  if (token is not None):
   token = oauth.Token(token.key.encode('ascii', 'ignore'), token.secret.encode('ascii', 'ignore'))
  oauth_server.verify_request(oauth_request, consumer, token)
 except oauth.Error:
  return False
 return True

def verify_oauth_request ( request , oauth_request , consumer , token = None ) : from treeio . core . api . auth . store import store if ( not store . check_nonce ( request , oauth_request , oauth_request [ 'oauth_nonce' ] ) ) : return False try : oauth_server = oauth . Server ( ) oauth_server . add_signature_method ( oauth . SignatureMethod_HMAC_SHA1 ( ) ) oauth_server . add_signature_method ( oauth . SignatureMethod_PLAINTEXT ( ) ) consumer = oauth . Consumer ( consumer . key . encode ( 'ascii' , 'ignore' ) , consumer . secret . encode ( 'ascii' , 'ignore' ) ) if ( token is not None ) : token = oauth . Token ( token . key . encode ( 'ascii' , 'ignore' ) , token . secret . encode ( 'ascii' , 'ignore' ) ) oauth_server . verify_request ( oauth_request , consumer , token ) except oauth . Error : return False return True
helper function to verify requests .