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

Handle 2FA error for OAuth client during login #10042

Merged
merged 6 commits into from
Jun 14, 2019

Conversation

aforcier
Copy link
Contributor

@aforcier aforcier commented Jun 13, 2019

Fixes #8754. Relies on wordpress-mobile/WordPress-FluxC-Android#1283, which should be reviewed and merged first.

When logging into a 2FA-enabled account with personal (non-production) OAuth clients, login will no longer halt. Instead, you'll get a warning about disabled APIs and the flow will proceed:

2fa-warning-android

See wordpress-mobile/WordPress-FluxC-Android#1283 for some background on the error and what it means.

To test:

  1. Generate an OAuth client id and secret for an account that has 2fa enabled (instructions).
  2. Update wp.OAUTH.APP.ID and wp.OAUTH.APP.SECRET in gradle.properties to those values.
  3. Run a clean build of the app, and log into the account the credentials belong to.
  4. After entering the 2FA code, confirm that you see the error in the screenshot above, and that login completes without incident.
  5. Confirm that the app otherwise behaves normally after login.
  6. Visit Me > Account Settings and Me > App Settings, and confirm you get the same toast warning.

Update release notes:

  • If there are user facing changes, I have added an item to RELEASE-NOTES.txt.

(This change only affects developers using personal OAuth credentials, no user-facing changes for WPAndroid.)

aforcier added 4 commits June 13, 2019 10:10
For non-production WP.com OAuth clients, some APIs (like fetching
settings) are disabled.

In this case, we should still show a warning, but allow login
to continue.
@aforcier aforcier added this to the 12.8 milestone Jun 13, 2019
@aforcier aforcier requested a review from shiki June 13, 2019 14:38
@aforcier aforcier added /Me and removed /Me labels Jun 13, 2019
Copy link
Member

@shiki shiki left a comment

Choose a reason for hiding this comment

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

@aforcier Thank you for fixing this! I have one nitpicky suggestion.

@@ -1480,6 +1480,7 @@
<string name="error_refresh_unauthorized_posts">You don\'t have permission to view or edit posts</string>
<string name="error_fetch_my_profile">Couldn\'t retrieve your profile</string>
<string name="error_fetch_account_settings">Couldn\'t retrieve your account settings</string>
<string name="error_disabled_apis">Could not fetch settings: Some APIs are disabled for this account + client ID combination.</string>
Copy link
Member

Choose a reason for hiding this comment

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

Some APIs are disabled for this account + client ID combination.

When I saw this, I thought there was something wrong with my actual WordPress user. What do you think about this?

Could not fetch settings: Some APIs are unavailable for this OAuth app ID and client ID combination.

The word "disable" connotes that it can be enabled somewhere but I believe it is impossible or we can't ever allow it, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm I see your point 🤔 but the OAuth app ID and client ID are the same thing. I think OAuth app ID is better for the message than client ID though since that's what we called the param in gradle.properties. 👍

What if we emphasized the 'OAuth app ID' part?

Could not fetch settings: Some APIs are unavailable for this OAuth app ID + account combination.

The word "disable" connotes that it can be enabled somewhere but I believe it is impossible or we can't ever allow it, right?

Basically, yes. I read it more as "works by default but not in this case", but "unavailable" works just as well for me and has less of a "default" connotation, which is maybe better. 👍 Will use it in the final message once we settle on one.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, oops. I meant secret instead of client ID there. 😅 But yep, your suggested message is great for me!

Could not fetch settings: Some APIs are unavailable for this OAuth app ID + account combination.

Copy link
Member

@shiki shiki left a comment

Choose a reason for hiding this comment

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

Hey, @aforcier. Again, thank you for fixing this. This will significantly improve the experience for external contributors.

I responded to your comment in #10042 (comment) and I believe we have reached an agreement. I have also merged wordpress-mobile/WordPress-FluxC-Android#1283.

Feel free to apply the necessary changes and merge this. I might not be able to merge it myself since I will be AFK next week.

Thank you very much. 🙏

@aforcier
Copy link
Contributor Author

@shiki thanks for reviewing! I'll update the message in this PR and update with FluxC develop now 👍

@aforcier aforcier modified the milestones: 12.8, 12.7 Jun 14, 2019
@aforcier aforcier merged commit ea70f1b into develop Jun 14, 2019
@aforcier aforcier deleted the issue/8754-2fa-oauth-client-error branch June 14, 2019 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Login failure after entering correct 2FA
2 participants