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

Fix credentials refreshment in Google OAuth2 #941

Merged
merged 1 commit into from
Apr 27, 2021

Conversation

adekbadek
Copy link
Member

All Submissions:

Changes proposed in this Pull Request:

Fixes an issue with Google OAuth, where even though refresh token was stored, it was not used to refresh credentials.
Two scenarios have to be handled here - if a user authorises the app for the first time, they will receive a refresh token (allowing them to connect after the access token expires). Otherwise, they will receive only an access token, which will expire after a certain amount to time.

How to test the changes in this Pull Request:

  1. Revoke access to the OAuth2 app on your Google permissions page and remove credentials (_newspack_google_oauth user meta) from the DB
  2. Complete the oauth flow (Add Google OAuth2 authentication flow  #935) to ensure the happy path is covered
  3. Remove credentials from the DB, observe the oauth flow can be completed again
  4. Revoke access in Google permissions page, observe the oauth flow can be completed again
  5. Invalidate the credentials by editing the user meta and changing the values of tokens to gibberish
  6. Observe the oauth flow can be completed again
  7. Revoke access, complete the flow again (to ensure you'll get a refresh token)
  8. Come back after an hour or more - observe the dashboard still displays the authenticated state

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@adekbadek adekbadek added the [Status] Needs Review The issue or pull request needs to be reviewed label Apr 26, 2021
@adekbadek adekbadek requested a review from dkoo April 26, 2021 15:11
Copy link
Contributor

@dkoo dkoo left a comment

Choose a reason for hiding this comment

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

Works as described—still authenticated after a whole day.

@github-actions github-actions bot added [Status] Approved The pull request has been reviewed and is ready to merge and removed [Status] Needs Review The issue or pull request needs to be reviewed labels Apr 27, 2021
@adekbadek adekbadek merged commit 92c4fce into master Apr 27, 2021
@adekbadek adekbadek deleted the fix/google-oauth-use-refresh-token branch April 27, 2021 16:18
@matticbot
Copy link
Contributor

🎉 This PR is included in version 1.37.0-alpha.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@matticbot
Copy link
Contributor

🎉 This PR is included in version 1.37.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released on @alpha released [Status] Approved The pull request has been reviewed and is ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants