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

Commit c9370219 authored by Alexandre Roux's avatar Alexandre Roux
Browse files

display notification when actual mail oauth needs refresh (until then...

display notification when actual mail oauth needs refresh (until then notification was due to a confusion between mail oauth and accountmanager)
parent d7b94c88
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;
}
+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();