Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2eec75fd authored by Romain Hunault's avatar Romain Hunault 🚴🏻
Browse files

Merge branch 'fix-token-5600' into 'dev'

Fix token 5600

See merge request e/apps/Mail!10
parents d7b94c88 fe2c6a4b
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ public abstract class OAuth2AuthorizationCodeFlowTokenProvider {
        return authTokens.get(email);
    }

    protected abstract void showAuthDialog(String email);
    protected abstract void showAuthDialog(String email) throws AuthenticationFailedException;

    /**
     * get refresh token got before
+3 −1
Original line number Diff line number Diff line
package foundation.e.mail.mail.oauth;

import foundation.e.mail.mail.AuthenticationFailedException;
import foundation.e.mail.mail.MessagingException;

public abstract class SpecificOAuth2TokenProvider {

    public abstract OAuth2AuthorizationCodeFlowTokenProvider.Tokens exchangeCode(String username, String code) throws AuthenticationFailedException;

    public abstract String refreshToken(String username, String refreshToken) throws AuthenticationFailedException;

    public abstract void showAuthDialog();
    public abstract void showAuthDialog() throws AuthenticationFailedException;
}
+2 −1
Original line number Diff line number Diff line
@@ -397,8 +397,9 @@ class ImapConnection {
            return attemptXOAuth2();
        } catch (NegativeImapResponseException e) {
            //TODO: Check response code so we don't needlessly invalidate the token.
            if(e.getMessage().contains("Too many simultaneous connections"))
                throw new MessagingException("Too many simultaneous connections");
            oauthTokenProvider.invalidateToken(settings.getUsername());

            if (!retryXoauth2WithNewToken) {
                throw handlePermanentXoauth2Failure(e);
            } else {
+4 −1
Original line number Diff line number Diff line
package foundation.e.mail.account;


import foundation.e.mail.mail.AuthenticationFailedException;
import retrofit2.Call;
import retrofit2.GsonConverterFactory;
import retrofit2.Retrofit;
@@ -30,7 +31,9 @@ public class GmailOAuth2TokenStore extends AndroidSpecificOAuth2TokenProvider {
    }

    @Override
    public void showAuthDialog() {
    public void showAuthDialog() throws AuthenticationFailedException {
        if(promptRequestHandler == null)
            throw new AuthenticationFailedException("No handler available");
        promptRequestHandler.handleGmailRedirectUrl(AUTHORIZATION_URL);
    }

+2 −1
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@ package foundation.e.mail.account;
import android.content.Context;
import android.content.SharedPreferences;

import foundation.e.mail.mail.AuthenticationFailedException;
import foundation.e.mail.mail.oauth.OAuth2AuthorizationCodeFlowTokenProvider;
import foundation.e.mail.mail.oauth.SpecificOAuth2TokenProvider;

@@ -35,7 +36,7 @@ public class K9OAuth2AuthorizationCodeFlowTokenProvider extends OAuth2Authorizat
    }

    @Override
    public void showAuthDialog(String email) {
    public void showAuthDialog(String email) throws AuthenticationFailedException {
        SpecificOAuth2TokenProvider provider = getSpecificProviderFromEmail(email);
        if (provider == null) return;
        provider.showAuthDialog();
Loading