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

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

wants to merge 3 commits into from

Conversation

mayankberi1
Copy link

  1. Fixed the code to handle content_type missing from headers. instead of defaulting it to JSON, now trying to load it to json, xml, or then simply returning the content. Code was failing when the content_type was missing but the content was not of json type.

  2. Handled the case where an exception was raised when the token URL responsed in a code other than 200 or 201. Instead of raising OauthException now returning the error code in a dictionary so that it can be handled or displayed.

1. Fixed the code to handle content_type missing from headers. instead of defaulting it to JSON, now trying to load it to json, xml, or then simply returning the content. Code was failing when the content_type was missing but the content was not of json type.

2. Handled the case where an exception was raised when the token URL responsed in a code other than 200 or 201. Instead of raising OauthException now returning the error code in a dictionary so that it can be handled or displayed.
@lepture
Copy link
Owner

lepture commented Nov 25, 2017

With the release of Authlib 0.2. It is stable enough to use the Flask Client in Authlib. It is more stable than Flask-OAuthlib.

lepture/authlib#2

@mayankberi1
Copy link
Author

mayankberi1 commented Nov 25, 2017 via email

type='invalid_response', data=data
)
return data
return {'accessToken':None,'code':resp.code, 'msg':resp.msg}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will introduce a break change.

type='invalid_response', data=data
)
return data
return {'accessToken':None,'code':resp.code, 'msg':resp.msg}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will introduce a break change.


if strict:
return content
else:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for else.

return json.loads(content)

except Exception as exception:
log.debug("The content is not json")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

single quote please.

And there are too many blank lines.

1. Fixed the code to handle content_type missing from headers. instead of defaulting it to JSON, now trying to load it to json, xml, or then simply returning the content. Code was failing when the content_type was missing but the content was not of json type.

2. Handled the case where an exception was raised when the token URL responsed in a code other than 200 or 201. Instead of raising OauthException now returning the error code in a dictionary so that it can be handled or displayed.
1. Fixed the code to handle content_type missing from headers. instead of defaulting it to JSON, now trying to load it to json, xml, or then simply returning the content. Code was failing when the content_type was missing but the content was not of json type.

2. Handled the case where an exception was raised when the token URL responsed in a code other than 200 or 201. Instead of raising OauthException now returning the error code in a dictionary so that it can be handled or displayed.
@mayankberi1
Copy link
Author

mayankberi1 commented Nov 26, 2017 via email

@lepture
Copy link
Owner

lepture commented Nov 26, 2017

You should catch the OAuthException with Flask error handler. Or you can use try catch pattern.

@mayankberi1
Copy link
Author

mayankberi1 commented Nov 26, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants