Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue with token URI not valid or returning error Bug#360 #361

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions flask_oauthlib/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,23 @@ def parse_response(resp, content, strict=False, content_type=None):
:param strict: strict mode for form urlencoded content
:param content_type: assign a content type manually
"""
if not content_type:
content_type = resp.headers.get('content-type', 'application/json')
ct, options = parse_options_header(content_type)
charset = options.get('charset', 'utf-8')

if not content_type:
try:
return json.loads(content)
except Exception as exception:
log.debug("The content is not json")

try:
return get_etree().fromstring(content)
except Exception as exception:
log.debug("The content is not XML")

if strict:
return content
return url_decode(content, charset=charset).to_dict()

if ct in ('application/json', 'text/javascript'):
if not content:
Expand All @@ -132,7 +146,7 @@ def parse_response(resp, content, strict=False, content_type=None):

if ct != 'application/x-www-form-urlencoded' and strict:
return content
charset = options.get('charset', 'utf-8')

return url_decode(content, charset=charset).to_dict()


Expand Down