<s> import os <EOL> import sys <EOL> try : <EOL> from urlparse import parse_qsl <EOL> except : <EOL> from cgi import parse_qsl <EOL> import oauth2 as oauth <EOL> REQUEST_TOKEN_URL = '<STR_LIT>' <EOL> ACCESS_TOKEN_URL = '<STR_LIT>' <EOL> AUTHORIZATION_URL = '<STR_LIT>' <EOL> SIGNIN_URL = '<STR_LIT>' <EOL> consumer_key = None <EOL> consumer_secret = None <EOL> if consumer_key is None or consumer_secret is None : <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> signature_method_hmac_sha1 = oauth . SignatureMethod_HMAC_SHA1 ( ) <EOL> oauth_consumer = oauth . Consumer ( key = consumer_key , secret = consumer_secret ) <EOL> oauth_client = oauth . Client ( oauth_consumer ) <EOL> print '<STR_LIT>' <EOL> resp , content = oauth_client . request ( REQUEST_TOKEN_URL , '<STR_LIT:GET>' ) <EOL> if resp [ '<STR_LIT:status>' ] != '<STR_LIT>' : <EOL> print '<STR_LIT>' % resp [ '<STR_LIT:status>' ] <EOL> else : <EOL> request_token = dict ( parse_qsl ( content ) ) <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' % ( AUTHORIZATION_URL , request_token [ '<STR_LIT>' ] ) <EOL> print '<STR_LIT>' <EOL> pincode = raw_input ( '<STR_LIT>' ) <EOL> token = oauth . Token ( request_token [ '<STR_LIT>' ] , request_token [ '<STR_LIT>' ] ) <EOL> token . set_verifier ( pincode ) <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> oauth_client = oauth . Client ( oauth_consumer , token ) <EOL> resp , content = oauth_client . request ( ACCESS_TOKEN_URL , method = '<STR_LIT:POST>' , body = '<STR_LIT>' % pincode ) <EOL> access_token = dict ( parse_qsl ( content ) ) <EOL> if resp [ '<STR_LIT:status>' ] != '<STR_LIT>' : <EOL> print '<STR_LIT>' % resp [ '<STR_LIT:status>' ] <EOL> print access_token <EOL> else : <EOL> print '<STR_LIT>' % access_token [ '<STR_LIT>' ] <EOL> print '<STR_LIT>' % access_token [ '<STR_LIT>' ] <EOL> print '<STR_LIT>' </s>
