def refresh_oauth_token(self, refresh_token):
r = requests.post(self._login_uri("<STR_LIT>"), data={<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": self.client_id,<EOL>"<STR_LIT>": self.client_secret,<EOL>"<STR_LIT>": refresh_token,<EOL>})<EOL>if r.status_code != <NUM_LIT:200>:<EOL><INDENT>raise ApiError("<STR_LIT>", r)<EOL><DEDENT>token = r.json()["<STR_LIT>"]<EOL>scopes = OAuthScopes.parse(r.json()["<STR_LIT>"])<EOL>expiry = datetime.now() + timedelta(seconds=r.json()['<STR_LIT>'])<EOL>refresh_token = r.json()['<STR_LIT>']<EOL>return token, scopes, expiry, refresh_token<EOL>
Some tokens are generated with refresh tokens (namely tokens generated
through an OAuth Exchange).  These tokens may be renewed, or "refreshed",
with the auth server, generating a new OAuth Token with a new (later)
expiry.  This method handles refreshing an OAuth Token using the refresh
token that was generated at the time of its issuance, and returns a new
OAuth token and refresh token for the same client and user.

:param refresh_token: The refresh token returned for the OAuth Token we
                      are renewing.
:type refresh_token: str

:returns: The new OAuth token, and a list of scopes the token has, when
          the token expires, and a refresh token that can generate a new
          valid token when this one is expired.
:rtype: tuple(str, list)

:raise ApiError: If the refresh fails..