#NEWLINE# def reddit_handle_oauth2_response( ) : #NEWLINE# #INDENT# access_args = { #NEWLINE# #INDENT# 'code' : flask . request . args . get ( 'code' ) , #NEWLINE# 'client_id' : reddit . consumer_key , #NEWLINE# 'redirect_uri' : flask . session . get ( ( '%s_oauthredir' % reddit . name ) ) , #NEWLINE# #UNINDENT# } #NEWLINE# access_args . update ( reddit . access_token_params ) #NEWLINE# auth_header = ( 'Basic %s' % base64 . b64encode ( ( '%s:%s' % ( reddit . consumer_key , reddit . consumer_secret ) ) . encode ( 'latin1' ) ) . strip ( ) . decode ( 'latin1' ) ) #NEWLINE# ( response , content ) = reddit . http_request ( reddit . expand_url ( reddit . access_token_url ) , method = reddit . access_token_method , data = urls . url_encode ( response ) , headers = { #NEWLINE# #INDENT# 'Authorization' : auth_header , #NEWLINE# 'User-Agent' : config . USER_AGENT , #NEWLINE# #UNINDENT# } ) #NEWLINE# data = client . parse_response ( response , content ) #NEWLINE# if ( response . code not in ( 200 , 201 ) ) : #NEWLINE# #INDENT# raise client . OAuthException ( ( 'Invalid response from %s' % reddit . name ) , type = 'invalid_response' , data = data ) #NEWLINE# #UNINDENT# return data