Skip to content

Commit

Permalink
Fix for werkzeug Request.url issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
lepture committed Sep 15, 2018
1 parent 5b0047f commit d8ab09f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
7 changes: 6 additions & 1 deletion authlib/flask/oauth1/authorization_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
OAuth1Request,
AuthorizationServer as _AuthorizationServer,
)
from authlib.common.encoding import to_unicode
from authlib.common.security import generate_token
from authlib.common.urls import url_encode
from authlib.deprecate import deprecate
Expand Down Expand Up @@ -193,4 +194,8 @@ def _create_oauth1_request():
body = _req.form.to_dict(flat=True)
else:
body = None
return OAuth1Request(_req.method, _req.url, body, _req.headers)

url = _req.base_url
if _req.query_string:
url = url + '?' + to_unicode(_req.query_string)
return OAuth1Request(_req.method, url, body, _req.headers)
13 changes: 7 additions & 6 deletions authlib/flask/oauth2/authorization_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,13 @@ def process_request(self, request):
body = q.form.to_dict(flat=True)
else:
body = None
return OAuth2Request(
q.method,
q.url,
body,
q.headers
)

# query string in werkzeug Request.url is very weird
# scope=profile%20email will be scope=profile email
url = q.base_url
if q.query_string:
url = url + '?' + to_unicode(q.query_string)
return OAuth2Request(q.method, url, body, q.headers)

def handle_response(self, status_code, payload, headers):
if isinstance(payload, dict):
Expand Down

0 comments on commit d8ab09f

Please sign in to comment.