def generate_request_for_request_token(consumer_key, signature_type, scopes, rsa_key=None, consumer_secret=None, auth_server_url=REQUEST_TOKEN_URL, next='oob', version='1.0'):
 request = atom.http_core.HttpRequest(auth_server_url, 'POST')
 if scopes:
  request.uri.query['scope'] = ' '.join(scopes)
 timestamp = str(int(time.time()))
 nonce = ''.join([str(random.randint(0, 9)) for i in xrange(15)])
 signature = None
 if (signature_type == HMAC_SHA1):
  signature = generate_hmac_signature(request, consumer_key, consumer_secret, timestamp, nonce, version, next=next)
 elif (signature_type == RSA_SHA1):
  signature = generate_rsa_signature(request, consumer_key, rsa_key, timestamp, nonce, version, next=next)
 else:
  return None
 request.headers['Authorization'] = generate_auth_header(consumer_key, timestamp, nonce, signature_type, signature, version, next)
 request.headers['Content-Length'] = '0'
 return request

def generate_request_for_request_token ( consumer_key , signature_type , scopes , rsa_key = None , consumer_secret = None , auth_server_url = REQUEST_TOKEN_URL , next = 'oob' , version = '1.0' ) : request = atom . http_core . HttpRequest ( auth_server_url , 'POST' ) if scopes : request . uri . query [ 'scope' ] = ' ' . join ( scopes ) timestamp = str ( int ( time . time ( ) ) ) nonce = '' . join ( [ str ( random . randint ( 0 , 9 ) ) for i in xrange ( 15 ) ] ) signature = None if ( signature_type == HMAC_SHA1 ) : signature = generate_hmac_signature ( request , consumer_key , consumer_secret , timestamp , nonce , version , next = next ) elif ( signature_type == RSA_SHA1 ) : signature = generate_rsa_signature ( request , consumer_key , rsa_key , timestamp , nonce , version , next = next ) else : return None request . headers [ 'Authorization' ] = generate_auth_header ( consumer_key , timestamp , nonce , signature_type , signature , version , next ) request . headers [ 'Content-Length' ] = '0' return request
creates request to be sent to auth server to get an oauth request token .