<s> """<STR_LIT>""" <EOL> import argparse <EOL> import sys <EOL> from oauth2client import client <EOL> DEFAULT_CLIENT_ID = None <EOL> DEFAULT_CLIENT_SECRET = None <EOL> SCOPE = u'<STR_LIT>' <EOL> parser = argparse . ArgumentParser ( description = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , default = DEFAULT_CLIENT_ID , <EOL> help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , default = DEFAULT_CLIENT_SECRET , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , default = None , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> def main ( client_id , client_secret , scopes ) : <EOL> """<STR_LIT>""" <EOL> flow = client . OAuth2WebServerFlow ( <EOL> client_id = client_id , <EOL> client_secret = client_secret , <EOL> scope = scopes , <EOL> user_agent = '<STR_LIT>' , <EOL> redirect_uri = '<STR_LIT>' ) <EOL> authorize_url = flow . step1_get_authorize_url ( ) <EOL> print ( '<STR_LIT>' <EOL> '<STR_LIT>' % ( authorize_url ) ) <EOL> print '<STR_LIT>' <EOL> code = raw_input ( '<STR_LIT>' ) . strip ( ) <EOL> try : <EOL> credential = flow . step2_exchange ( code ) <EOL> except client . FlowExchangeError , e : <EOL> print '<STR_LIT>' % e <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> else : <EOL> print ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> % ( credential . access_token , credential . refresh_token ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> args = parser . parse_args ( ) <EOL> configured_scopes = [ SCOPE ] <EOL> if not ( any ( [ args . client_id , DEFAULT_CLIENT_ID ] ) and <EOL> any ( [ args . client_secret , DEFAULT_CLIENT_SECRET ] ) ) : <EOL> raise AttributeError ( '<STR_LIT>' ) <EOL> if args . additional_scopes : <EOL> configured_scopes . extend ( args . additional_scopes . replace ( '<STR_LIT:U+0020>' , '<STR_LIT>' ) . split ( '<STR_LIT:U+002C>' ) ) <EOL> main ( args . client_id , args . client_secret , configured_scopes ) </s>
