Skip to content

Commit

Permalink
There is no oauth_callback when fetch access token
Browse files Browse the repository at this point in the history
  • Loading branch information
coopfeathy committed Jan 11, 2021
1 parent 567f097 commit 0de4dd8
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 23 deletions.
7 changes: 2 additions & 5 deletions authlib/integrations/base_client/async_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,14 @@ async def create_authorization_url(self, redirect_uri=None, **kwargs):
state = request_token['oauth_token']
return {'url': url, 'request_token': request_token, 'state': state}

async def fetch_access_token(self, redirect_uri=None, request_token=None, **kwargs):
async def fetch_access_token(self, request_token=None, **kwargs):
"""Fetch access token in one step.
:param redirect_uri: Callback or Redirect URI that is used in
previous :meth:`authorize_redirect`.
:param request_token: A previous request token for OAuth 1.
:param kwargs: Extra parameters to fetch access token.
:return: A token dict.
"""
async with self._get_oauth_client() as client:
client.redirect_uri = redirect_uri
if request_token is None:
raise MissingRequestTokenError()
# merge request token with verifier
Expand All @@ -60,7 +58,6 @@ async def fetch_access_token(self, redirect_uri=None, request_token=None, **kwar
client.token = token
params = self.access_token_params or {}
token = await client.fetch_access_token(self.access_token_url, **params)
client.redirect_uri = None
return token


Expand Down
7 changes: 1 addition & 6 deletions authlib/integrations/base_client/sync_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,17 +149,14 @@ def create_authorization_url(self, redirect_uri=None, **kwargs):
state = request_token['oauth_token']
return {'url': url, 'request_token': request_token, 'state': state}

def fetch_access_token(self, redirect_uri=None, request_token=None, **kwargs):
def fetch_access_token(self, request_token=None, **kwargs):
"""Fetch access token in one step.
:param redirect_uri: Callback or Redirect URI that is used in
previous :meth:`authorize_redirect`.
:param request_token: A previous request token for OAuth 1.
:param kwargs: Extra parameters to fetch access token.
:return: A token dict.
"""
with self._get_oauth_client() as client:
client.redirect_uri = redirect_uri
if request_token is None:
raise MissingRequestTokenError()
# merge request token with verifier
Expand All @@ -169,8 +166,6 @@ def fetch_access_token(self, redirect_uri=None, request_token=None, **kwargs):
client.token = token
params = self.access_token_params or {}
token = client.fetch_access_token(self.access_token_url, **params)
# reset redirect_uri
client.redirect_uri = None
return token


Expand Down
4 changes: 0 additions & 4 deletions authlib/integrations/django_client/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ def authorize_access_token(self, request, **kwargs):
raise OAuthError(description='Missing "request_token" in temporary data')

params['request_token'] = data['request_token']
redirect_uri = data.get('redirect_uri')
if redirect_uri:
params['redirect_uri'] = redirect_uri

params.update(kwargs)
self.framework.clear_state_data(request.session, state)
return self.fetch_access_token(**params)
Expand Down
4 changes: 0 additions & 4 deletions authlib/integrations/flask_client/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ def authorize_access_token(self, **kwargs):
raise OAuthError(description='Missing "request_token" in temporary data')

params['request_token'] = data['request_token']
redirect_uri = data.get('redirect_uri')
if redirect_uri:
params['redirect_uri'] = redirect_uri

params.update(kwargs)
self.framework.clear_state_data(session, state)
token = self.fetch_access_token(**params)
Expand Down
4 changes: 0 additions & 4 deletions authlib/integrations/starlette_client/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ async def authorize_access_token(self, request, **kwargs):
raise OAuthError(description='Missing "request_token" in temporary data')

params['request_token'] = data['request_token']
redirect_uri = data.get('redirect_uri')
if redirect_uri:
params['redirect_uri'] = redirect_uri

params.update(kwargs)
await self.framework.clear_state_data(request.session, state)
return await self.fetch_access_token(**params)
Expand Down

0 comments on commit 0de4dd8

Please sign in to comment.