def refresh_token(token, session=None):
session = session or HTTP_SESSION<EOL>refresh_data = dict(<EOL>refresh_token=token.refresh_token,<EOL>client_id=token.consumer_key,<EOL>client_secret=token.consumer_secret,<EOL>grant_type='<STR_LIT>'<EOL>)<EOL>resp = session.post(REFRESH_TOKEN_URL, data=refresh_data)<EOL>resp_json = resp.json()<EOL>if '<STR_LIT:error>' in resp_json:<EOL><INDENT>message = resp_json['<STR_LIT:error>']<EOL>description = resp_json.get('<STR_LIT>', '<STR_LIT>')<EOL>if any(description):<EOL><INDENT>message = u'<STR_LIT>'.format(message, description)<EOL><DEDENT>raise OAuthTokenExpiredError(message)<EOL><DEDENT>return OAuthToken(<EOL>access_token=resp_json['<STR_LIT>'],<EOL>refresh_token=token.refresh_token,<EOL>consumer_key=token.consumer_key,<EOL>consumer_secret=token.consumer_secret<EOL>)<EOL>
Refresh Google OAuth token.

    :param OAuthToken token:
      the token to refresh

    :param requests.Session session:
      Optional `requests` session to use.