Skip to content

Commit 4a37ed5

Browse files
authored
Merge pull request #1 from Telkonet/update/stateless_oauth2
Set 'redirect_uri' with app config callback URL
2 parents e3081a1 + 2b71a3d commit 4a37ed5

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

flask_oauthlib/client.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,6 @@ def authorize(self, callback=None, state=None, **kwargs):
523523
# state can be function for generate a random string
524524
state = state()
525525

526-
session['%s_oauthredir' % self.name] = callback
527526
url = client.prepare_request_uri(
528527
self.expand_url(self.authorize_url),
529528
redirect_uri=callback,
@@ -623,12 +622,11 @@ def handle_oauth1_response(self):
623622

624623
def handle_oauth2_response(self):
625624
"""Handles an oauth2 authorization response."""
626-
627625
client = self.make_client()
628626
remote_args = {
629627
'code': request.args.get('code'),
630628
'client_secret': self.consumer_secret,
631-
'redirect_uri': session.get('%s_oauthredir' % self.name)
629+
'redirect_uri': current_app.config['OAUTH_CALLBACK_URL']
632630
}
633631
log.debug('Prepare oauth2 remote args %r', remote_args)
634632
remote_args.update(self.access_token_params)
@@ -656,7 +654,6 @@ def handle_oauth2_response(self):
656654
'Unsupported access_token_method: %s' %
657655
self.access_token_method
658656
)
659-
660657
data = parse_response(resp, content, content_type=self.content_type)
661658
if resp.code not in (200, 201):
662659
raise OAuthException(
@@ -680,7 +677,6 @@ def authorized_response(self):
680677

681678
# free request token
682679
session.pop('%s_oauthtok' % self.name, None)
683-
session.pop('%s_oauthredir' % self.name, None)
684680
return data
685681

686682
def authorized_handler(self, f):

0 commit comments

Comments
 (0)