OAuth: nothing asks the user to sign in again when a token is rejected or can't be refreshed
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- ios, swift
- Domain
- authentication, mobile
Research direction
Start with IMAPError.authenticationFailed in the IMAP module and trace where it stops, then read AccountManager.checkAndRenewExpirations() and the AccountManager.error path for failed refreshes. The account model, the mailbox list and the OAuthButton in account settings are the places a 'needs sign-in' state would surface. Done means a rejected or non-refreshable token marks the account, shows one tap to sign in, and skips mail operations until then, while network errors do not. The design choice of where that state lives needs maintainer input first.
Written by the indexing model from the issue text.
Description
Summary
When a server rejects an OAuth token, or a refresh fails because the refresh token is no longer valid, the app has no way to tell the user to sign in again.
(Found by reading the code.)
Details
IMAPError.authenticationFailed(added by the work for #535) is thrown, but nothing above the IMAP module looks for it.- A failed refresh in
AccountManager.checkAndRenewExpirations()setsAccountManager.error = .authorization(error). #619 covers that these errors are never shown. - The account isn't marked as needing sign-in, so every later mail operation tries again with the same credential.
OAuthButtonin the account settings is the only place to sign in again, and the user has to know to go there.
Expected behavior
- An account whose credential was rejected is marked as needing sign-in.
- The user is told, and one tap leads to the sign-in screen.
- Mail operations for that account are skipped until then, not retried with a credential known to be bad.
- A temporary failure (no network, server outage) does none of this.
Suggested fix
Record a "needs sign-in" state on the account when a refresh fails with invalid_grant, or when a server rejects a token that was just refreshed. Show it in the mailbox list and in account settings, and clear it on the next successful sign-in.
References
- RFC 6749, section 5.2,
invalid_grant: "The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client." - Google, OAuth 2.0 for installed apps, on
invalid_grant: "Authenticate the user again and ask for user consent to obtain new tokens." - RFC 5530, section 3,
AUTHENTICATIONFAILED: "there's no point in trying the same login/password again later". - Related: #605, #619.
In thunderbird-android
MessagingController.handleAuthenticationFailureraises the authentication-error notification.AuthenticationErrorNotificationControllerbuilds it; tapping it opens the server settings, where sign-in is offered.isAuthenticationProblemskips sync and sending for an OAuth account with no stored sign-in.MailSyncWorkerskips background sync in the same case.
Links are pinned to ac1f0e8.
- Dominant language
- Swift
- Stars
- 1.3k
- Forks
- 51
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 33
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from thunderbird/thunderbird-ios
-
Account: Authorization's description returns the stored credential, including the refresh tokenOpen
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
thunderbird/thunderbird-ios#666 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
thunderbird/thunderbird-ios#664 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
thunderbird/thunderbird-ios#658 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
thunderbird/thunderbird-ios#657 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
thunderbird/thunderbird-ios#647 ·
Maintainers usually reply within 1 day
All issues in thunderbird/thunderbird-ios
Similar issues
-
enhancement help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
heysidhant/appvanish#4 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
timfraedrich/OutRun#121 ·
-
deferred tooling
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
mauwii/pokerchipcase#157 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 78/100