mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-24 07:01:05 +00:00
Added parameters OAuth profiles
This commit is contained in:
parent
77f8a84b4a
commit
0bd493dadc
2 changed files with 20 additions and 1 deletions
|
@ -60,8 +60,10 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
@ -277,6 +279,13 @@ public class EmailProvider implements Parcelable {
|
|||
provider.oauth.tokenEndpoint = xml.getAttributeValue(null, "tokenEndpoint");
|
||||
provider.oauth.redirectUri = xml.getAttributeValue(null, "redirectUri");
|
||||
provider.oauth.privacy = xml.getAttributeValue(null, "privacy");
|
||||
provider.oauth.prompt = xml.getAttributeValue(null, "prompt");
|
||||
} else if ("parameter".equals(name)) {
|
||||
if (provider.oauth.parameters == null)
|
||||
provider.oauth.parameters = new LinkedHashMap<>();
|
||||
provider.oauth.parameters.put(
|
||||
xml.getAttributeValue(null, "key"),
|
||||
xml.getAttributeValue(null, "value"));
|
||||
} else
|
||||
throw new IllegalAccessException(name);
|
||||
} else if (eventType == XmlPullParser.END_TAG) {
|
||||
|
@ -1280,5 +1289,7 @@ public class EmailProvider implements Parcelable {
|
|||
String tokenEndpoint;
|
||||
String redirectUri;
|
||||
String privacy;
|
||||
String prompt;
|
||||
Map<String, String> parameters;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,6 +86,7 @@ import java.util.Collections;
|
|||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -363,7 +364,11 @@ public class FragmentOAuth extends FragmentBase {
|
|||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
prefs.edit().putString("oauth." + provider.id, authState.jsonSerializeString()).apply();
|
||||
|
||||
Map<String, String> params = new HashMap<>();
|
||||
Map<String, String> params = new LinkedHashMap<>();
|
||||
|
||||
if (provider.oauth.parameters != null)
|
||||
for (String key : provider.oauth.parameters.keySet())
|
||||
params.put(key, provider.oauth.parameters.get(key));
|
||||
|
||||
if ("gmail".equals(provider.id))
|
||||
params.put("access_type", "offline");
|
||||
|
@ -398,6 +403,9 @@ public class FragmentOAuth extends FragmentBase {
|
|||
if (provider.oauth.pcke)
|
||||
authRequestBuilder.setCodeVerifier(CodeVerifierUtil.generateRandomCodeVerifier());
|
||||
|
||||
if (!TextUtils.isEmpty(provider.oauth.prompt))
|
||||
authRequestBuilder.setPrompt(provider.oauth.prompt);
|
||||
|
||||
// For offline access
|
||||
if ("gmail".equals(provider.id))
|
||||
authRequestBuilder.setPrompt("consent");
|
||||
|
|
Loading…
Reference in a new issue