From 101f8f20284c6e6b72723b8935c416339338b42f Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 21 Feb 2023 10:13:42 +0100 Subject: [PATCH] OAuth params --- .../main/java/eu/faircode/email/ServiceAuthenticator.java | 8 ++++++++ app/src/main/res/xml/providers.xml | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/ServiceAuthenticator.java b/app/src/main/java/eu/faircode/email/ServiceAuthenticator.java index 5198218220..3cb4887ab8 100644 --- a/app/src/main/java/eu/faircode/email/ServiceAuthenticator.java +++ b/app/src/main/java/eu/faircode/email/ServiceAuthenticator.java @@ -24,6 +24,7 @@ import static eu.faircode.email.GmailState.TYPE_GOOGLE; import android.accounts.AuthenticatorException; import android.accounts.OperationCanceledException; import android.content.Context; +import android.text.TextUtils; import androidx.annotation.NonNull; @@ -41,6 +42,8 @@ import org.json.JSONException; import java.io.IOException; import java.util.Date; +import java.util.LinkedHashMap; +import java.util.Map; import java.util.Objects; import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; @@ -182,6 +185,10 @@ public class ServiceAuthenticator extends Authenticator { ErrorHolder holder = new ErrorHolder(); Semaphore semaphore = new Semaphore(0); + Map params = new LinkedHashMap<>(); + if (provider.oauth.tokenScopes) + params.put("scope", TextUtils.join(" ", provider.oauth.scopes)); + Log.i("OAuth refresh user=" + id + ":" + user); AppAuthConfiguration config = new AppAuthConfiguration.Builder() .setBrowserMatcher(new BrowserMatcher() { @@ -195,6 +202,7 @@ public class ServiceAuthenticator extends Authenticator { authState.performActionWithFreshTokens( authService, clientAuth, + //params, new AuthState.AuthStateAction() { @Override public void execute(String accessToken, String idToken, AuthorizationException error) { diff --git a/app/src/main/res/xml/providers.xml b/app/src/main/res/xml/providers.xml index 8ed0ff448f..e4a9f742ee 100644 --- a/app/src/main/res/xml/providers.xml +++ b/app/src/main/res/xml/providers.xml @@ -189,7 +189,11 @@ redirectUri="msauth.eu.faircode.email://auth" scopes="profile,openid,email,offline_access,https://outlook.office.com/IMAP.AccessAsUser.All,https://outlook.office.com/SMTP.Send,https://outlook.office.com/POP.AccessAsUser.All" tokenEndpoint="https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token" - tokenScopes="true" /> + tokenScopes="true"> + +