-
-
Notifications
You must be signed in to change notification settings - Fork 796
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
WIP: Feat/verify token exists before saving #1058
WIP: Feat/verify token exists before saving #1058
Conversation
75dd790
to
b0fa93f
Compare
for more information, see https://pre-commit.ci
Can anyone help me in this PR? @jdp , @jezdez, @brad , @stephane, @n2ygk, @synasius and @masci I am trying to prevent the AccessTokens and RefreshTokens from being recreated everytime we hit the create_token_response method at: https://github.com/wagnerdelima/django-oauth-toolkit/blob/d35f030960617cb4d0dbe9a3e89b797df2e7cf0c/oauth2_provider/views/mixins.py#L117-L124. I've been struggling for a lont time. So, two tests are failing, one of them is https://github.com/wagnerdelima/django-oauth-toolkit/blob/ab74586865ce062862e09f06f080dc465ad09ee5/tests/test_authorization_code.py#L690. So, the first time, Then the second time it is called, line 717, it fails with:
As if the access token created recently did nt exist in the database. After some more investigation, I found out that it fails here:
at the authorization_code.py file, at the validate_token_response method, from the oauthlib library. So the validate_code method, found at: https://github.com/wagnerdelima/django-oauth-toolkit/blob/b0fa93f93119d675aa84a41e953e7d0202dfc980/oauth2_provider/oauth2_validators.py#L410-L424 has a grant, but it's expired therefore the return is False. Somehow, the create authorizatio code is expired: Let me know if I have been clear enough. |
Can you provide a short concise description of what you are trying to accomplish? Are you saying there's a bug where the token gets saved multiple times? Are you sure that is happening? |
Fixes #
There is no issue associated with this project. However, at my framwork's list of issues you can find why I opened this pull request: wagnerdelima/drf-social-oauth2#80 (comment)
Description of the Change
Everytime save_bearer_token is called, a refresh token and access token is created. However, it's wise vefirying if they already exist in database and if they are valid (not expired or revoked). So, only then we create new tokens, otherwise, return the already existing tokens.
Checklist
CHANGELOG.md
updated (only for user relevant changes)AUTHORS