Skip to content

Commit

Permalink
Place refresh_token() arguments under caller's control.
Browse files Browse the repository at this point in the history
  • Loading branch information
btimby committed Mar 3, 2017
1 parent cf3ff0a commit f22426b
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions requests_oauthlib/oauth2_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,6 @@ def refresh_token(self, token_url, refresh_token=None, body='', auth=None,

refresh_token = refresh_token or self.token.get('refresh_token')

log.debug('Adding auto refresh key word arguments %s.',
self.auto_refresh_kwargs)
kwargs.update(self.auto_refresh_kwargs)
body = self._client.prepare_refresh_body(body=body,
refresh_token=refresh_token, scope=self.scope, **kwargs)
log.debug('Prepared refresh token request body %s', body)
Expand Down Expand Up @@ -334,21 +331,9 @@ def request(self, method, url, data=None, headers=None, withhold_token=False,
log.debug('Auto refresh is set, attempting to refresh at %s.',
self.auto_refresh_url)

refresh_kwargs = {}
# If caller provided auto_refresh_kwargs, don't send kwargs
if not self.auto_refresh_kwargs:
# Send kargs (preserve behavior) if caller did not
# specify auto_refresh_kwargs.
refresh_kwargs.update(kwargs)
# If caller did not specify auth in kwargs, provide one.
if client_id and client_secret and 'auth' not in refresh_kwargs:
log.debug('Encoding client_id "%s" with client_secret as Basic auth credentials.', client_id)
refresh_kwargs['auth'] = \
requests.auth.HTTPBasicAuth(client_id, client_secret)
# Call refresh_token(), it merges self.auto_refresh_kwargs
# if provided by caller.
# Call refresh_token(), pass any kwargs registered to it.
token = self.refresh_token(
self.auto_refresh_url, **refresh_kwargs
self.auto_refresh_url, **self.auth_refresh_kwargs
)
if self.token_updater:
log.debug('Updating token to %s using %s.',
Expand Down

0 comments on commit f22426b

Please sign in to comment.