<s> import urllib <EOL> __author__ = '<STR_LIT>' <EOL> PROGRAMMATIC_AUTH_LABEL = '<STR_LIT>' <EOL> AUTHSUB_AUTH_LABEL = '<STR_LIT>' <EOL> def generate_client_login_request_body ( email , password , service , source , <EOL> account_type = '<STR_LIT>' , captcha_token = None , <EOL> captcha_response = None ) : <EOL> """<STR_LIT>""" <EOL> request_fields = { '<STR_LIT>' : email , <EOL> '<STR_LIT>' : password , <EOL> '<STR_LIT>' : account_type , <EOL> '<STR_LIT>' : service , <EOL> '<STR_LIT:source>' : source } <EOL> if captcha_token and captcha_response : <EOL> request_fields [ '<STR_LIT>' ] = captcha_token <EOL> request_fields [ '<STR_LIT>' ] = captcha_response <EOL> return urllib . urlencode ( request_fields ) <EOL> GenerateClientLoginRequestBody = generate_client_login_request_body <EOL> def get_client_login_token_string ( http_body ) : <EOL> """<STR_LIT>""" <EOL> for response_line in http_body . splitlines ( ) : <EOL> if response_line . startswith ( '<STR_LIT>' ) : <EOL> return response_line [ <NUM_LIT:5> : ] <EOL> return None <EOL> GetClientLoginTokenString = get_client_login_token_string <EOL> def get_captcha_challenge ( http_body , <EOL> captcha_base_url = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> contains_captcha_challenge = False <EOL> captcha_parameters = { } <EOL> for response_line in http_body . splitlines ( ) : <EOL> if response_line . startswith ( '<STR_LIT>' ) : <EOL> contains_captcha_challenge = True <EOL> elif response_line . startswith ( '<STR_LIT>' ) : <EOL> captcha_parameters [ '<STR_LIT>' ] = response_line [ <NUM_LIT> : ] <EOL> elif response_line . startswith ( '<STR_LIT>' ) : <EOL> captcha_parameters [ '<STR_LIT:url>' ] = '<STR_LIT>' % ( captcha_base_url , <EOL> response_line [ <NUM_LIT:11> : ] ) <EOL> if contains_captcha_challenge : <EOL> return captcha_parameters <EOL> else : <EOL> return None <EOL> GetCaptchaChallenge = get_captcha_challenge <EOL> class ClientLoginToken ( object ) : <EOL> def __init__ ( self , token_string ) : <EOL> self . token_string = token_string <EOL> def modify_request ( self , http_request ) : <EOL> http_request . headers [ '<STR_LIT>' ] = '<STR_LIT>' % ( <EOL> self . token_string , ) <EOL> ModifyRequest = modify_request </s>
