#NEWLINE# def refresh_token( self , token ) : #NEWLINE# #INDENT# 'Access Tokens only last for one hour from the point of being issued.\n\n        When a token has expired it needs to be refreshed this method takes an\n        expired token and refreshes it.\n\n        token parameter can be either a token object or a token string.\n\n        ' #NEWLINE# if ( not hasattr ( token , 'key' ) ) : #NEWLINE# #INDENT# token = YahooToken . from_string ( token ) #NEWLINE# #UNINDENT# params = self . get_base_params ( ) #NEWLINE# params [ 'oauth_token' ] = token . key #NEWLINE# params [ 'oauth_token_secret' ] = token . secret #NEWLINE# params [ 'oauth_session_handle' ] = token . session_handle #NEWLINE# oauth_request = oauth . Request . from_consumer_and_token ( self . consumer , token = token , http_url = ACCESS_TOKEN_URL , http_method = 'POST' , parameters = params ) #NEWLINE# yql_logger . debug ( 'oauth_request: %s' , oauth_request ) #NEWLINE# oauth_request . sign_request ( self . hmac_sha1_signature , self . consumer , token ) #NEWLINE# url = oauth_request . to_url ( ) #NEWLINE# yql_logger . debug ( 'oauth_url: %s' , url ) #NEWLINE# postdata = oauth_request . to_postdata ( ) #NEWLINE# yql_logger . debug ( 'oauth_postdata: %s' , postdata ) #NEWLINE# ( resp , content ) = self . http . request ( token , 'POST' , postdata ) #NEWLINE# if ( resp . get ( 'status' ) == '200' ) : #NEWLINE# #INDENT# access_token = YahooToken . from_string ( content ) #NEWLINE# yql_logger . debug ( 'oauth_access_token: %s' , access_token ) #NEWLINE# access_token . timestamp = oauth_request [ 'oauth_timestamp' ] #NEWLINE# return access_token #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise YQLError ( resp , content , url )