Index: trunk/src/org/openstreetmap/josm/data/Preferences.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/Preferences.java	(revision 19706)
+++ trunk/src/org/openstreetmap/josm/data/Preferences.java	(revision 19707)
@@ -86,5 +86,6 @@
     /** remove if key equals */
     private static final String[] OBSOLETE_PREF_KEYS = {
-        // nothing ATM
+        "oauth.access-token.key", // OAuth 1.0a token, unused since OAuth 1.0a was removed (#22810). To remove end of 2027
+        "oauth.access-token.secret", // OAuth 1.0a token, unused since OAuth 1.0a was removed (#22810). To remove end of 2027
     };
 
Index: trunk/src/org/openstreetmap/josm/data/UserIdentityManager.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/UserIdentityManager.java	(revision 19706)
+++ trunk/src/org/openstreetmap/josm/data/UserIdentityManager.java	(revision 19707)
@@ -86,6 +86,4 @@
     private String userName;
     private UserInfo userInfo;
-    private boolean accessTokenKeyChanged;
-    private boolean accessTokenSecretChanged;
 
     private UserIdentityManager() {
@@ -297,25 +295,13 @@
             }
             break;
-        case "oauth.access-token.key":
-            accessTokenKeyChanged = true;
-            break;
-        case "oauth.access-token.secret":
-            accessTokenSecretChanged = true;
-            break;
-        default: // Do nothing
-            if (evt.getKey() != null && evt.getKey().equals("oauth.access-token.parameters.OAuth20." + OsmApi.getOsmApi().getHost())) {
-                accessTokenKeyChanged = true;
-                accessTokenSecretChanged = true;
-            }
-        }
-        // oauth.access-token.parameters.OAuth20.api.openstreetmap.org
-
-        if (accessTokenKeyChanged && accessTokenSecretChanged) {
-            accessTokenKeyChanged = false;
-            accessTokenSecretChanged = false;
-            if (OsmApi.isUsingOAuthAndOAuthSetUp(OsmApi.getOsmApi())) {
-                getInstance().initFromOAuth();
-            } else if (OsmApi.isUsingOAuth()) {
-                setAnonymous();
+        default:
+            // the OAuth 2 token of the current server was stored or removed, e.g. oauth.access-token.object.OAuth20.api.openstreetmap.org;
+            // its parameters are kept when it is removed, so they do not tell
+            if (("oauth.access-token.object.OAuth20." + OsmApi.getOsmApi().getHost()).equals(evt.getKey())) {
+                if (OsmApi.isUsingOAuthAndOAuthSetUp(OsmApi.getOsmApi())) {
+                    getInstance().initFromOAuth();
+                } else if (OsmApi.isUsingOAuth()) {
+                    setAnonymous();
+                }
             }
         }
Index: trunk/src/org/openstreetmap/josm/data/oauth/OAuth20Parameters.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/oauth/OAuth20Parameters.java	(revision 19706)
+++ trunk/src/org/openstreetmap/josm/data/oauth/OAuth20Parameters.java	(revision 19707)
@@ -16,4 +16,6 @@
 
 import org.openstreetmap.josm.spi.preferences.Config;
+import org.openstreetmap.josm.tools.Logging;
+import org.openstreetmap.josm.tools.Utils;
 
 /**
@@ -131,8 +133,24 @@
     }
 
+    /**
+     * {@inheritDoc}
+     * <p>
+     * The parameters are stored under the host of the API, where the access token of the server stores its
+     * parameters as well.
+     */
     @Override
     public void rememberPreferences() {
-        Config.getPref().put("oauth.access-token.parameters." + OAuthVersion.OAuth20 + "." + this.apiUrl,
-                this.toPreferencesString());
+        if (Utils.isEmpty(this.apiUrl)) {
+            // there is no server to store them for
+            Logging.warn("OAuth parameters of client id {0} have no API URL and are not stored", this.clientId);
+            return;
+        }
+        final String key = OAuthParameters.getPreferenceKey(this.apiUrl);
+        Config.getPref().put(key, this.toPreferencesString());
+        // earlier versions of JOSM stored them under the API URL
+        final String apiUrlKey = "oauth.access-token.parameters." + OAuthVersion.OAuth20 + "." + this.apiUrl;
+        if (!key.equals(apiUrlKey)) {
+            Config.getPref().put(apiUrlKey, null);
+        }
     }
 
Index: trunk/src/org/openstreetmap/josm/data/oauth/OAuth20Token.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/oauth/OAuth20Token.java	(revision 19706)
+++ trunk/src/org/openstreetmap/josm/data/oauth/OAuth20Token.java	(revision 19707)
@@ -50,4 +50,25 @@
     public OAuth20Token(IOAuthParameters oauthParameters, String json) throws OAuth20Exception {
         this(oauthParameters, new InputStreamReader(new ByteArrayInputStream(json.getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8));
+    }
+
+    /**
+     * Create a bearer token from the access token alone, such as a token issued outside JOSM and pasted by the user.
+     * It has no refresh token, and works with nothing else: the parameters only need the API URL the token is for.
+     * @param oauthParameters The parameters for the OAuth token
+     * @param accessToken The access token
+     * @return The bearer token
+     * @since 19707
+     */
+    public static OAuth20Token fromAccessToken(IOAuthParameters oauthParameters, String accessToken) {
+        final String json = Json.createObjectBuilder()
+                .add(ACCESS_TOKEN, accessToken)
+                .add(TOKEN_TYPE, "bearer")
+                .build().toString();
+        try {
+            return new OAuth20Token(oauthParameters, json);
+        } catch (OAuth20Exception e) {
+            // both required fields are present
+            throw new JosmRuntimeException(e);
+        }
     }
 
Index: trunk/src/org/openstreetmap/josm/data/oauth/OAuthParameters.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/oauth/OAuthParameters.java	(revision 19706)
+++ trunk/src/org/openstreetmap/josm/data/oauth/OAuthParameters.java	(revision 19707)
@@ -37,4 +37,6 @@
     private static final String OSM_API_DEV = "https://api06.dev.openstreetmap.org/api";
     private static final String OSM_API_MASTER = "https://master.apis.dev.openstreetmap.org/api";
+    /** Whether the default parameters are used; one setting for each host, with the setting for all hosts as fallback */
+    private static final String USE_DEFAULT = "oauth.settings.use-default";
 
     private OAuthParameters() {
@@ -81,8 +83,9 @@
     /**
      * Get the OAuth 2.0 parameters the user entered in the advanced OAuth settings and saved with
-     * {@link IOAuthParameters#rememberPreferences()}. Until a token exists, this is the only place a
-     * client id for a server not in {@link #createDefault(String, OAuthVersion)} can come from.
-     * {@link OAuth20Parameters#rememberPreferences()} keys by the API URL as given; callers may pass
-     * either the URL or its host, so both are tried.
+     * {@link IOAuthParameters#rememberPreferences()}, or the parameters of the access token of the server. Until a
+     * token exists, this is the only place a client id for a server not in
+     * {@link #createDefault(String, OAuthVersion)} can come from.
+     * {@link OAuth20Parameters#rememberPreferences()} keys by the host of the API, as the access token is; earlier
+     * versions of JOSM keyed them by the API URL, so callers pass that too.
      * @param keys The preference key suffixes to try, in order
      * @return The remembered parameters, or {@code null} if none are saved or they cannot be parsed
@@ -111,10 +114,72 @@
     }
 
+    /**
+     * Get the preference key under which the OAuth 2.0 parameters for the server of an API are stored. This is the
+     * key of the access token of that server too, see {@link org.openstreetmap.josm.io.auth.CredentialsAgent}.
+     * @param apiUrl The API URL, or the host of the API
+     * @return The preference key
+     * @since 19707
+     */
+    static String getPreferenceKey(String apiUrl) {
+        return "oauth.access-token.parameters." + OAuthVersion.OAuth20 + "." + getHost(apiUrl);
+    }
+
+    /**
+     * Get the host of an API, which is what the OAuth settings and the access token of a server are stored under.
+     * @param apiUrl The API URL, or the host of the API
+     * @return The host, or {@code apiUrl} itself if it is not a URL (including {@code null})
+     * @since 19707
+     */
+    public static String getHost(String apiUrl) {
+        if (Utils.isEmpty(apiUrl)) {
+            return apiUrl;
+        }
+        try {
+            final String host = new URI(apiUrl).getHost();
+            return host == null ? apiUrl : host;
+        } catch (URISyntaxException e) {
+            Logging.trace(e);
+            return apiUrl;
+        }
+    }
+
+    /**
+     * Determines whether the default OAuth 2.0 parameters are used for the server of an API, that is the ones built
+     * into JOSM or published by the server, rather than the ones the user entered in the advanced OAuth settings.
+     * <p>
+     * This is a setting of each server. Until it is set for a server, the setting earlier versions of JOSM had
+     * for all servers is used.
+     * @param apiUrl The API URL, or the host of the API
+     * @return {@code true} if the default parameters are used
+     * @since 19707
+     */
+    public static boolean isUseDefault(String apiUrl) {
+        final boolean useDefaultForAll = Config.getPref().getBoolean(USE_DEFAULT, true);
+        if (Utils.isEmpty(apiUrl)) {
+            return useDefaultForAll;
+        }
+        return Config.getPref().getBoolean(USE_DEFAULT + "." + getHost(apiUrl), useDefaultForAll);
+    }
+
+    /**
+     * Sets whether the default OAuth 2.0 parameters are used for the server of an API.
+     * @param apiUrl The API URL, or the host of the API
+     * @param useDefault {@code true} to use the default parameters, {@code false} to use the ones the user entered
+     * @see #isUseDefault(String)
+     * @since 19707
+     */
+    public static void setUseDefault(String apiUrl, boolean useDefault) {
+        if (!Utils.isEmpty(apiUrl)) {
+            Config.getPref().putBoolean(USE_DEFAULT + "." + getHost(apiUrl), useDefault);
+        }
+    }
+
     private static JsonObject getRFC8414Parameters(String apiUrl) {
         HttpClient client = null;
         try {
             final URI apiURI = new URI(apiUrl);
-            final URL rfc8414URL = new URI(apiURI.getScheme(), apiURI.getHost(),
-                    "/.well-known/oauth-authorization-server", null).toURL();
+            // keep the port, as for a development server on http://localhost:3000
+            final URL rfc8414URL = new URI(apiURI.getScheme(), null, apiURI.getHost(), apiURI.getPort(),
+                    "/.well-known/oauth-authorization-server", null, null).toURL();
             client = HttpClient.create(rfc8414URL);
             HttpClient.Response response = client.connect();
@@ -147,5 +212,4 @@
         final String clientSecret;
         final String redirectUri = "http://127.0.0.1:8111/oauth_authorization";
-        final String baseUrl;
         apiUrl = OsmApi.normalizeApiUrl(apiUrl == null ? OsmApi.getOsmApi().getServerUrl() : apiUrl);
         switch (apiUrl) {
@@ -181,5 +245,4 @@
                 clientSecret = null;
         }
-        baseUrl = apiUrl;
         // Check if the server is RFC 8414 compliant
         try {
@@ -208,6 +271,19 @@
             Logging.trace(e);
         }
-        // Fall back to guessing the parameters.
-        return new OAuth20Parameters(clientId, clientSecret, baseUrl, apiUrl, redirectUri);
+        // Fall back to the endpoints of openstreetmap-website, which is what OSM API servers run
+        return new OAuth20Parameters(clientId, clientSecret, getWebsite(apiUrl) + "/oauth2", apiUrl, redirectUri);
+    }
+
+    /**
+     * Get the website of an OSM API server, where openstreetmap-website has its OAuth 2.0 endpoints: the API URL
+     * without its {@code /api}, except for the default OSM API, which is served from a host of its own.
+     * @param apiUrl The normalized API URL
+     * @return The website URL
+     */
+    private static String getWebsite(String apiUrl) {
+        if (OSM_API_DEFAULT.equals(apiUrl)) {
+            return Config.getUrls().getOSMWebsite();
+        }
+        return apiUrl.replaceAll("/api$", "");
     }
 
@@ -231,5 +307,7 @@
 
     /**
-     * Replies a set of parameters as defined in the preferences.
+     * Replies a set of parameters as defined in the preferences: the parameters of the access token of the server,
+     * otherwise the parameters the user entered, unless the server is set to {@link #isUseDefault(String) use the
+     * default parameters}, otherwise the {@link #createDefault(String, OAuthVersion) default parameters}.
      *
      * @param oAuthVersion The OAuth version to use.
@@ -240,18 +318,11 @@
     public static IOAuthParameters createFromApiUrl(String apiUrl, OAuthVersion oAuthVersion) {
         apiUrl = OsmApi.normalizeApiUrl(apiUrl);
-        final String originalApiUrl = apiUrl;
         // We actually need the host
-        if (apiUrl.startsWith("https://") || apiUrl.startsWith("http://")) {
-            try {
-                apiUrl = new URI(apiUrl).getHost();
-            } catch (URISyntaxException syntaxException) {
-                Logging.trace(apiUrl);
-            }
-        }
+        final String host = getHost(apiUrl);
         switch (oAuthVersion) {
             case OAuth20:
             case OAuth21: // Right now, OAuth 2.1 will work with our OAuth 2.0 implementation
                 try {
-                    IOAuthToken storedToken = CredentialsManager.getInstance().lookupOAuthAccessToken(apiUrl);
+                    IOAuthToken storedToken = CredentialsManager.getInstance().lookupOAuthAccessToken(host);
                     if (storedToken != null) {
                         return storedToken.getParameters();
@@ -260,11 +331,14 @@
                     Logging.trace(e);
                 }
-                IOAuthParameters remembered = createFromPreferences(originalApiUrl, apiUrl);
-                if (remembered != null) {
-                    return remembered;
-                }
-                // Use the URL as it was given: apiUrl is the host by now, which is never a valid URL, so
-                // createDefault() would silently fall back to the API currently configured in the preferences.
-                return createDefault(originalApiUrl, oAuthVersion);
+                if (!isUseDefault(apiUrl)) {
+                    // the API URL is where earlier versions of JOSM stored them
+                    IOAuthParameters remembered = createFromPreferences(host, apiUrl);
+                    if (remembered != null) {
+                        return remembered;
+                    }
+                }
+                // Use the URL as it was given: the host is never a valid URL, so createDefault() would silently
+                // fall back to the API currently configured in the preferences.
+                return createDefault(apiUrl, oAuthVersion);
             default:
                 throw new IllegalArgumentException("Unknown OAuth version: " + oAuthVersion);
Index: trunk/src/org/openstreetmap/josm/data/oauth/OsmPrivileges.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/oauth/OsmPrivileges.java	(revision 19706)
+++ 	(revision )
@@ -1,130 +1,0 @@
-// License: GPL. For details, see LICENSE file.
-package org.openstreetmap.josm.data.oauth;
-
-/**
- * List of permissions granted to the current OSM connection.
- * @since 2747
- */
-public class OsmPrivileges {
-    private boolean allowWriteApi;
-    private boolean allowWriteGpx;
-    private boolean allowReadGpx;
-    private boolean allowReadPrefs;
-    private boolean allowWritePrefs;
-    private boolean allowModifyNotes;
-    private boolean allowWriteDiary;
-
-    /**
-     * Determines if the client is allowed to modify the map.
-     * @return {@code true} if the client is allowed to modify the map, {@code false} otherwise
-     */
-    public boolean isAllowWriteApi() {
-        return allowWriteApi;
-    }
-
-    /**
-     * Sets whether the client is allowed to modify the map.
-     * @param allowWriteApi {@code true} if the client is allowed to modify the map, {@code false} otherwise
-     */
-    public void setAllowWriteApi(boolean allowWriteApi) {
-        this.allowWriteApi = allowWriteApi;
-    }
-
-    /**
-     * Determines if the client is allowed to upload GPS traces.
-     * @return {@code true} if the client is allowed to upload GPS traces, {@code false} otherwise
-     */
-    public boolean isAllowWriteGpx() {
-        return allowWriteGpx;
-    }
-
-    /**
-     * Sets whether the client is allowed to upload GPS traces.
-     * @param allowWriteGpx {@code true} if the client is allowed to upload GPS traces, {@code false} otherwise
-     */
-    public void setAllowWriteGpx(boolean allowWriteGpx) {
-        this.allowWriteGpx = allowWriteGpx;
-    }
-
-    /**
-     * Determines if the client is allowed to read private GPS traces.
-     * @return {@code true} if the client is allowed to read private GPS traces, {@code false} otherwise
-     */
-    public boolean isAllowReadGpx() {
-        return allowReadGpx;
-    }
-
-    /**
-     * Sets whether the client is allowed to read private GPS traces.
-     * @param allowReadGpx {@code true} if the client is allowed to read private GPS traces, {@code false} otherwise
-     */
-    public void setAllowReadGpx(boolean allowReadGpx) {
-        this.allowReadGpx = allowReadGpx;
-    }
-
-    /**
-     * Determines if the client is allowed to read user preferences.
-     * @return {@code true} if the client is allowed to read user preferences, {@code false} otherwise
-     */
-    public boolean isAllowReadPrefs() {
-        return allowReadPrefs;
-    }
-
-    /**
-     * Sets whether the client is allowed to read user preferences.
-     * @param allowReadPrefs {@code true} if the client is allowed to read user preferences, {@code false} otherwise
-     */
-    public void setAllowReadPrefs(boolean allowReadPrefs) {
-        this.allowReadPrefs = allowReadPrefs;
-    }
-
-    /**
-     * Determines if the client is allowed to modify user preferences.
-     * @return {@code true} if the client is allowed to modify user preferences, {@code false} otherwise
-     */
-    public boolean isAllowWritePrefs() {
-        return allowWritePrefs;
-    }
-
-    /**
-     * Sets whether the client is allowed to modify user preferences.
-     * @param allowWritePrefs {@code true} if the client is allowed to modify user preferences, {@code false} otherwise
-     */
-    public void setAllowWritePrefs(boolean allowWritePrefs) {
-        this.allowWritePrefs = allowWritePrefs;
-    }
-
-    /**
-     * Determines if the client is allowed to modify notes.
-     * @return {@code true} if the client is allowed to modify notes, {@code false} otherwise
-     */
-    public boolean isAllowModifyNotes() {
-        return allowModifyNotes;
-    }
-
-    /**
-     * Sets whether the client is allowed to modify notes.
-     * @param allowModifyNotes {@code true} if the client is allowed to modify notes, {@code false} otherwise
-     */
-    public void setAllowModifyNotes(boolean allowModifyNotes) {
-        this.allowModifyNotes = allowModifyNotes;
-    }
-
-    /**
-     * Determines if the client is allowed to write diary.
-     * @return {@code true} if the client is allowed to write diary, {@code false} otherwise
-     * @since 17972
-     */
-    public boolean isAllowWriteDiary() {
-        return allowWriteDiary;
-    }
-
-    /**
-     * Sets whether the client is allowed to write diary.
-     * @param allowWriteDiary {@code true} if the client is allowed to write diary, {@code false} otherwise
-     * @since 17972
-     */
-    public void setAllowWriteDiary(boolean allowWriteDiary) {
-        this.allowWriteDiary = allowWriteDiary;
-    }
-}
Index: trunk/src/org/openstreetmap/josm/data/oauth/osm/OsmScopes.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/oauth/osm/OsmScopes.java	(revision 19706)
+++ trunk/src/org/openstreetmap/josm/data/oauth/osm/OsmScopes.java	(revision 19707)
@@ -21,4 +21,14 @@
     write_gpx,
     /** Modify notes */
-    write_notes
+    write_notes;
+
+    /**
+     * Get the scopes JOSM requests when it is authorized. An OAuth 2.0 application which JOSM is to use must be
+     * registered with at least these.
+     * @return the scopes, in the order they are requested
+     * @since 19707
+     */
+    public static OsmScopes[] getJosmScopes() {
+        return new OsmScopes[] {read_gpx, write_gpx, read_prefs, write_prefs, write_api, write_notes};
+    }
 }
Index: trunk/src/org/openstreetmap/josm/gui/ExceptionDialogUtil.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/ExceptionDialogUtil.java	(revision 19706)
+++ trunk/src/org/openstreetmap/josm/gui/ExceptionDialogUtil.java	(revision 19707)
@@ -16,5 +16,8 @@
 import javax.swing.JOptionPane;
 
+import org.openstreetmap.josm.actions.PreferencesAction;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec;
+import org.openstreetmap.josm.gui.preferences.server.ServerAccessPreference;
 import org.openstreetmap.josm.io.ChangesetClosedException;
 import org.openstreetmap.josm.io.IllegalDataException;
@@ -26,4 +29,5 @@
 import org.openstreetmap.josm.io.OsmTransferException;
 import org.openstreetmap.josm.tools.ExceptionUtil;
+import org.openstreetmap.josm.tools.ImageProvider;
 import org.openstreetmap.josm.tools.Logging;
 import org.openstreetmap.josm.tools.bugreport.BugReportExceptionHandler;
@@ -369,9 +373,22 @@
      */
     public static void explainMissingOAuthAccessTokenException(MissingOAuthAccessTokenException e) {
-        showErrorDialog(
+        final ButtonSpec[] buttons = {
+                new ButtonSpec(tr("Open preferences"), new ImageProvider("preference"),
+                        tr("Open the OSM server preferences, to authorize JOSM or to enter an Access Token"), null),
+                new ButtonSpec(tr("Close"), new ImageProvider("cancel"), tr("Close this message"), null)
+        };
+        final int answer = HelpAwareOptionPane.showOptionDialog(
+                MainApplication.getMainFrame(),
                 ExceptionUtil.explainMissingOAuthAccessTokenException(e),
                 tr("Authentication failed"),
+                JOptionPane.ERROR_MESSAGE,
+                null,
+                buttons,
+                buttons[0],
                 ht("/ErrorMessages#MissingOAuthAccessToken")
         );
+        if (answer == 0) {
+            PreferencesAction.forPreferenceTab(tr("Preferences"), null, ServerAccessPreference.class).run();
+        }
     }
 
Index: trunk/src/org/openstreetmap/josm/gui/MainApplication.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/MainApplication.java	(revision 19706)
+++ trunk/src/org/openstreetmap/josm/gui/MainApplication.java	(revision 19707)
@@ -120,5 +120,4 @@
 import org.openstreetmap.josm.gui.mappaint.RenderingCLI;
 import org.openstreetmap.josm.gui.mappaint.loader.MapPaintStyleLoader;
-import org.openstreetmap.josm.gui.oauth.OAuthAuthorizationWizard;
 import org.openstreetmap.josm.gui.preferences.ToolbarPreferences;
 import org.openstreetmap.josm.gui.preferences.display.LafPreference;
@@ -140,5 +139,4 @@
 import org.openstreetmap.josm.io.NetworkManager;
 import org.openstreetmap.josm.io.OnlineResource;
-import org.openstreetmap.josm.io.OsmConnection;
 import org.openstreetmap.josm.io.OsmTransferException;
 import org.openstreetmap.josm.io.auth.AbstractCredentialsAgent;
@@ -1111,5 +1109,4 @@
     static void setupCallbacks() {
         HttpClient.setFactory(Http1Client::new);
-        OsmConnection.setOAuthAccessTokenFetcher(OAuthAuthorizationWizard::obtainAccessToken);
         AbstractCredentialsAgent.setCredentialsProvider(CredentialDialog::promptCredentials);
         MessageNotifier.setNotifierCallback(MainApplication::notifyNewMessages);
Index: trunk/src/org/openstreetmap/josm/gui/oauth/AbstractAuthorizationUI.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/oauth/AbstractAuthorizationUI.java	(revision 19706)
+++ 	(revision )
@@ -1,148 +1,0 @@
-// License: GPL. For details, see LICENSE file.
-package org.openstreetmap.josm.gui.oauth;
-
-import java.util.Objects;
-
-import org.openstreetmap.josm.data.oauth.IOAuthParameters;
-import org.openstreetmap.josm.data.oauth.IOAuthToken;
-import org.openstreetmap.josm.data.oauth.OAuthParameters;
-import org.openstreetmap.josm.data.oauth.OAuthVersion;
-import org.openstreetmap.josm.gui.widgets.VerticallyScrollablePanel;
-import org.openstreetmap.josm.tools.CheckParameterUtil;
-
-/**
- * This is the abstract base class for the three authorisation UIs.
- *
- * @since 2746
- */
-public abstract class AbstractAuthorizationUI extends VerticallyScrollablePanel {
-    /**
-     * The property name for the Access Token property
-     */
-    public static final String ACCESS_TOKEN_PROP = AbstractAuthorizationUI.class.getName() + ".accessToken";
-
-    private String apiUrl;
-    private final AdvancedOAuthPropertiesPanel pnlAdvancedProperties;
-    private transient IOAuthToken accessToken;
-
-    /**
-     * Constructs a new {@code AbstractAuthorizationUI} for the given API URL.
-     * @param apiUrl The OSM API URL (may be null)
-     * @param oAuthVersion The oauth version to use
-     * @since 18991
-     */
-    protected AbstractAuthorizationUI(String apiUrl, OAuthVersion oAuthVersion) {
-        this.pnlAdvancedProperties = new AdvancedOAuthPropertiesPanel(oAuthVersion);
-        if (apiUrl != null) {
-            setApiUrl(apiUrl);
-        }
-    }
-
-    protected void fireAccessTokenChanged(IOAuthToken oldValue, IOAuthToken newValue) {
-        firePropertyChange(ACCESS_TOKEN_PROP, oldValue, newValue);
-    }
-
-    /**
-     * Replies the URL of the OSM API for which this UI is currently trying to retrieve an OAuth
-     * Access Token
-     *
-     * @return the API URL
-     */
-    public String getApiUrl() {
-        return apiUrl;
-    }
-
-    /**
-     * Sets the URL of the OSM API for which this UI is currently trying to retrieve an OAuth
-     * Access Token
-     *
-     * @param apiUrl the api URL
-     */
-    public void setApiUrl(String apiUrl) {
-        this.apiUrl = apiUrl;
-        this.pnlAdvancedProperties.setApiUrl(apiUrl);
-    }
-
-    /**
-     * Replies the panel for entering advanced OAuth parameters (see {@link OAuthParameters})
-     *
-     * @return the panel for entering advanced OAuth parameters
-     * @see #getOAuthParameters()
-     */
-    protected AdvancedOAuthPropertiesPanel getAdvancedPropertiesPanel() {
-        return pnlAdvancedProperties;
-    }
-
-    /**
-     * Replies the current set of advanced OAuth parameters in this UI
-     *
-     * @return the current set of advanced OAuth parameters in this UI
-     */
-    public IOAuthParameters getOAuthParameters() {
-        return pnlAdvancedProperties.getAdvancedParameters();
-    }
-
-    /**
-     * Replies the retrieved Access Token. null, if no Access Token was retrieved.
-     *
-     * @return the retrieved Access Token
-     */
-    public IOAuthToken getAccessToken() {
-        return accessToken;
-    }
-
-    /**
-     * Sets the current Access Token. This will fire a property change event for {@link #ACCESS_TOKEN_PROP}
-     * if the access token has changed
-     *
-     * @param accessToken the new access token. null, to clear the current access token
-     */
-    protected void setAccessToken(IOAuthToken accessToken) {
-        IOAuthToken oldValue = this.accessToken;
-        this.accessToken = accessToken;
-        if (oldValue == null ^ this.accessToken == null) {
-            fireAccessTokenChanged(oldValue, this.accessToken);
-        } else if (oldValue == null && this.accessToken == null) {
-            // no change - don't fire an event
-        } else if (!Objects.equals(oldValue, this.accessToken)) {
-            fireAccessTokenChanged(oldValue, this.accessToken);
-        }
-    }
-
-    /**
-     * Get the OAuth version for this AuthorizationUI
-     * @return The OAuth version
-     * @since 18991
-     */
-    public OAuthVersion getOAuthVersion() {
-        return this.pnlAdvancedProperties.getAdvancedParameters().getOAuthVersion();
-    }
-
-    /**
-     * Replies true if this UI currently has an Access Token
-     *
-     * @return true if this UI currently has an Access Token
-     */
-    public boolean hasAccessToken() {
-        return accessToken != null;
-    }
-
-    /**
-     * Replies whether the user has chosen to save the Access Token in the JOSM
-     * preferences or not.
-     *
-     * @return true if the user has chosen to save the Access Token
-     */
-    public abstract boolean isSaveAccessTokenToPreferences();
-
-    /**
-     * Initializes the authorisation UI.
-     *
-     * @param paramApiUrl the API URL. Must not be null.
-     * @throws IllegalArgumentException if paramApiUrl is null
-     */
-    public void initialize(String paramApiUrl) {
-        CheckParameterUtil.ensureParameterNotNull(paramApiUrl, "paramApiUrl");
-        pnlAdvancedProperties.initialize(paramApiUrl);
-    }
-}
Index: trunk/src/org/openstreetmap/josm/gui/oauth/AccessTokenInfoPanel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/oauth/AccessTokenInfoPanel.java	(revision 19706)
+++ 	(revision )
@@ -1,105 +1,0 @@
-// License: GPL. For details, see LICENSE file.
-package org.openstreetmap.josm.gui.oauth;
-
-import static org.openstreetmap.josm.tools.I18n.tr;
-
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.Insets;
-
-import javax.swing.JCheckBox;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-
-import org.openstreetmap.josm.data.oauth.IOAuthToken;
-import org.openstreetmap.josm.data.oauth.OAuth20Token;
-import org.openstreetmap.josm.data.oauth.OAuthAccessTokenHolder;
-import org.openstreetmap.josm.gui.widgets.JosmTextField;
-import org.openstreetmap.josm.tools.JosmRuntimeException;
-
-/**
- * Displays the key of an OAuth Access Token.
- * @since 2746 (modified for OAuth 2 in 18991)
- */
-public class AccessTokenInfoPanel extends JPanel {
-
-    private final JosmTextField tfAccessTokenKey = new JosmTextField(null, null, 0, false);
-    private final JCheckBox cbSaveAccessTokenInPreferences = new JCheckBox(tr("Save Access Token in preferences"));
-
-    /**
-     * Constructs a new {@code AccessTokenInfoPanel}.
-     */
-    public AccessTokenInfoPanel() {
-        build();
-    }
-
-    protected final void build() {
-        setLayout(new GridBagLayout());
-        GridBagConstraints gc = new GridBagConstraints();
-
-        // the access token key
-        gc.anchor = GridBagConstraints.NORTHWEST;
-        gc.fill = GridBagConstraints.HORIZONTAL;
-        gc.weightx = 0.0;
-        gc.insets = new Insets(0, 0, 3, 3);
-        add(new JLabel(tr("Access Token Key:")), gc);
-
-        gc.gridx = 1;
-        gc.weightx = 1.0;
-        add(tfAccessTokenKey, gc);
-        tfAccessTokenKey.setEditable(false);
-
-        // the access token secret
-        gc.gridx = 0;
-        gc.gridy = 1;
-        gc.weightx = 0.0;
-        gc.insets = new Insets(0, 0, 3, 3);
-        add(new JLabel(tr("Access Token Secret:")), gc);
-
-        gc.weightx = 1.0;
-        // the checkbox
-        gc.gridx = 0;
-        gc.gridy = 2;
-        gc.gridwidth = 2;
-        add(cbSaveAccessTokenInPreferences, gc);
-        cbSaveAccessTokenInPreferences.setToolTipText(tr(
-                "<html>Select to save the Access Token in the JOSM preferences.<br>"
-                + "Unselect to use the Access Token in this JOSM session only.</html>"
-        ));
-        cbSaveAccessTokenInPreferences.setSelected(OAuthAccessTokenHolder.getInstance().isSaveToPreferences());
-
-        // filler - grab the remaining space
-        gc.gridx = 0;
-        gc.gridy = 3;
-        gc.weightx = 1.0;
-        gc.weighty = 1.0;
-        gc.fill = GridBagConstraints.BOTH;
-        gc.gridwidth = 2;
-        add(new JPanel(), gc);
-    }
-
-    /**
-     * Displays the key and secret in <code>token</code>.
-     *
-     * @param token the access  token. If null, the content in the info panel is cleared
-     */
-    public void setAccessToken(IOAuthToken token) {
-        if (token == null) {
-            tfAccessTokenKey.setText("");
-            return;
-        }
-        if (token instanceof OAuth20Token) {
-            tfAccessTokenKey.setText(((OAuth20Token) token).getBearerToken());
-        } else {
-            throw new JosmRuntimeException("Unknown token type: " + token.getClass());
-        }
-    }
-
-    public void setSaveToPreferences(boolean saveToPreferences) {
-        cbSaveAccessTokenInPreferences.setSelected(saveToPreferences);
-    }
-
-    public boolean isSaveToPreferences() {
-        return cbSaveAccessTokenInPreferences.isSelected();
-    }
-}
Index: trunk/src/org/openstreetmap/josm/gui/oauth/AdvancedOAuthPropertiesPanel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/oauth/AdvancedOAuthPropertiesPanel.java	(revision 19706)
+++ trunk/src/org/openstreetmap/josm/gui/oauth/AdvancedOAuthPropertiesPanel.java	(revision 19707)
@@ -10,7 +10,11 @@
 import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
+import java.util.Objects;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 import javax.swing.BorderFactory;
 import javax.swing.JCheckBox;
+import javax.swing.JComponent;
 import javax.swing.JLabel;
 import javax.swing.JOptionPane;
@@ -22,4 +26,5 @@
 import org.openstreetmap.josm.data.oauth.OAuthParameters;
 import org.openstreetmap.josm.data.oauth.OAuthVersion;
+import org.openstreetmap.josm.data.oauth.osm.OsmScopes;
 import org.openstreetmap.josm.gui.HelpAwareOptionPane;
 import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec;
@@ -30,5 +35,4 @@
 import org.openstreetmap.josm.gui.widgets.SelectAllOnFocusGainedDecorator;
 import org.openstreetmap.josm.gui.widgets.VerticallyScrollablePanel;
-import org.openstreetmap.josm.spi.preferences.Config;
 import org.openstreetmap.josm.tools.CheckParameterUtil;
 import org.openstreetmap.josm.tools.ImageProvider;
@@ -37,11 +41,10 @@
  * Panel allowing the user to setup advanced OAuth parameters:
  * <ul>
- * <li>Consumer key</li>
- * <li>Consumer secret</li>
- * <li>Request token URL</li>
+ * <li>Client ID</li>
+ * <li>Client secret</li>
+ * <li>Redirect URI</li>
  * <li>Access token URL</li>
  * <li>Authorize URL</li>
- * <li>OSM login URL</li>
- * <li>OSM logout URL</li>
+ * <li>Access token, which can be pasted instead of authorizing JOSM</li>
  * </ul>
  *
@@ -58,9 +61,11 @@
 
     private final JCheckBox cbUseDefaults = new JCheckBox(tr("Use default settings"));
-    private final JosmTextField tfConsumerKey = new JosmTextField();
-    private final JosmTextField tfConsumerSecret = new JosmTextField();
-    private final JosmTextField tfRequestTokenURL = new JosmTextField();
+    private final JosmTextField tfClientId = new JosmTextField();
+    private final JosmTextField tfClientSecret = new JosmTextField();
+    private final JosmTextField tfRedirectUri = new JosmTextField();
     private final JosmTextField tfAccessTokenURL = new JosmTextField();
     private final JosmTextField tfAuthoriseURL = new JosmTextField();
+    private final JLabel lblAccessToken = new JLabel(tr("Access Token:"));
+    private final JosmTextField tfAccessToken = new JosmTextField();
     private final OAuthVersion oauthVersion;
     private transient UseDefaultItemListener ilUseDefault;
@@ -88,36 +93,36 @@
         add(cbUseDefaults, gc);
 
-        // -- consumer key
+        // -- client id
         gc.gridy = 1;
         gc.weightx = 0.0;
         gc.gridwidth = 1;
-        add(new JLabel(tr("Client ID:")), gc);
-
-        gc.gridx = 1;
-        gc.weightx = 1.0;
-        add(tfConsumerKey, gc);
-        SelectAllOnFocusGainedDecorator.decorate(tfConsumerKey);
-
-        // -- consumer secret
+        add(label(tr("Client ID:"), tfClientId), gc);
+
+        gc.gridx = 1;
+        gc.weightx = 1.0;
+        add(tfClientId, gc);
+        SelectAllOnFocusGainedDecorator.decorate(tfClientId);
+
+        // -- client secret
         gc.gridy++;
         gc.gridx = 0;
         gc.weightx = 0.0;
-        add(new JLabel(tr("Client Secret:")), gc);
-
-        gc.gridx = 1;
-        gc.weightx = 1.0;
-        add(tfConsumerSecret, gc);
-        SelectAllOnFocusGainedDecorator.decorate(tfConsumerSecret);
-
-        // -- request token URL
+        add(label(tr("Client Secret:"), tfClientSecret), gc);
+
+        gc.gridx = 1;
+        gc.weightx = 1.0;
+        add(tfClientSecret, gc);
+        SelectAllOnFocusGainedDecorator.decorate(tfClientSecret);
+
+        // -- redirect URI
         gc.gridy++;
         gc.gridx = 0;
         gc.weightx = 0.0;
-        add(new JLabel(tr("Redirect URL:")), gc);
-
-        gc.gridx = 1;
-        gc.weightx = 1.0;
-        add(tfRequestTokenURL, gc);
-        SelectAllOnFocusGainedDecorator.decorate(tfRequestTokenURL);
+        add(label(tr("Redirect URL:"), tfRedirectUri), gc);
+
+        gc.gridx = 1;
+        gc.weightx = 1.0;
+        add(tfRedirectUri, gc);
+        SelectAllOnFocusGainedDecorator.decorate(tfRedirectUri);
 
         // -- access token URL
@@ -125,5 +130,5 @@
         gc.gridx = 0;
         gc.weightx = 0.0;
-        add(new JLabel(tr("Access Token URL:")), gc);
+        add(label(tr("Access Token URL:"), tfAccessTokenURL), gc);
 
         gc.gridx = 1;
@@ -136,5 +141,5 @@
         gc.gridx = 0;
         gc.weightx = 0.0;
-        add(new JLabel(tr("Authorize URL:")), gc);
+        add(label(tr("Authorize URL:"), tfAuthoriseURL), gc);
 
         gc.gridx = 1;
@@ -143,9 +148,24 @@
         SelectAllOnFocusGainedDecorator.decorate(tfAuthoriseURL);
 
+        // -- access token: not one of the settings, so it can be pasted whether or not they are the default ones
+        gc.gridy++;
+        gc.gridx = 0;
+        gc.weightx = 0.0;
+        lblAccessToken.setLabelFor(tfAccessToken);
+        add(lblAccessToken, gc);
+
+        gc.gridx = 1;
+        gc.weightx = 1.0;
+        add(tfAccessToken, gc);
+        SelectAllOnFocusGainedDecorator.decorate(tfAccessToken);
+
+        setToolTips();
+
         ilUseDefault = new UseDefaultItemListener();
         cbUseDefaults.addItemListener(ilUseDefault);
-        cbUseDefaults.setSelected(Config.getPref().getBoolean("oauth.settings.use-default", true));
+        cbUseDefaults.setSelected(true);
+        setChildComponentsVisible(false);
         cbUseDefaults.addItemListener(e -> fireParametersChanged());
-        tfConsumerKey.getDocument().addDocumentListener(new DocumentListener() {
+        tfClientId.getDocument().addDocumentListener(new DocumentListener() {
             @Override
             public void insertUpdate(DocumentEvent e) {
@@ -165,6 +185,66 @@
     }
 
+    /**
+     * Creates the label of a field, which has the tool tip of the field.
+     * @param text the text of the label
+     * @param field the field
+     * @return the label
+     */
+    private static JLabel label(String text, JosmTextField field) {
+        final JLabel label = new JLabel(text);
+        label.setLabelFor(field);
+        return label;
+    }
+
+    /**
+     * Explains each field, for the fields and their labels.
+     */
+    private void setToolTips() {
+        final String scopes = Stream.of(OsmScopes.getJosmScopes()).map(Enum::name).collect(Collectors.joining(", "));
+        cbUseDefaults.setToolTipText(tr("<html>Use the OAuth settings JOSM has built in for this server, or which the server publishes.<br>"
+                + "Untick to enter the settings of an OAuth 2.0 application you registered on the server yourself.</html>"));
+        tfClientId.setToolTipText(tr("<html>The Client ID of an OAuth 2.0 application registered on this server.<br>"
+                + "On an openstreetmap-website server, register one under My Settings &gt; OAuth 2 applications,<br>"
+                + "with the redirect URL below and the permissions {0}.</html>", scopes));
+        tfClientSecret.setToolTipText(tr("<html>Only needed if the application is registered as confidential.<br>"
+                + "The applications JOSM has built in are public clients and have none.</html>"));
+        tfRedirectUri.setToolTipText(tr("<html>Must be exactly the redirect URL registered with the application.<br>"
+                + "JOSM receives the authorization at {0}, by remote control.</html>", "http://127.0.0.1:8111/oauth_authorization"));
+        tfAccessTokenURL.setToolTipText(tr("<html>Where JOSM gets the Access Token from.<br>"
+                + "Taken from the OAuth metadata of the server if it publishes any; on an openstreetmap-website server,<br>"
+                + "this is the address of the website followed by {0}, not the API URL.</html>", "/oauth2/token"));
+        tfAuthoriseURL.setToolTipText(tr("<html>Where the web browser is sent to authorize JOSM.<br>"
+                + "Taken from the OAuth metadata of the server if it publishes any; on an openstreetmap-website server,<br>"
+                + "this is the address of the website followed by {0}, not the API URL.</html>", "/oauth2/authorize"));
+        tfAccessToken.setToolTipText(tr("<html>The Access Token JOSM uses for this server.<br>"
+                + "A token issued outside JOSM can be pasted here instead of authorizing JOSM; it needs the permissions {0}.</html>",
+                scopes));
+        for (Component c : getComponents()) {
+            if (c instanceof JLabel && ((JLabel) c).getLabelFor() instanceof JComponent) {
+                ((JLabel) c).setToolTipText(((JComponent) ((JLabel) c).getLabelFor()).getToolTipText());
+            }
+        }
+    }
+
     private void fireParametersChanged() {
         firePropertyChange(PARAMETERS_CHANGED_PROP, null, null);
+    }
+
+    /**
+     * Get the access token as entered in the panel.
+     * @return the access token, without surrounding white space; empty if there is none
+     * @since 19707
+     */
+    public String getAccessToken() {
+        return tfAccessToken.getText().trim();
+    }
+
+    /**
+     * Sets the access token to be displayed.
+     * @param accessToken the access token, or {@code null} if there is none
+     * @since 19707
+     */
+    public void setAccessToken(String accessToken) {
+        tfAccessToken.setText(accessToken);
     }
 
@@ -181,13 +261,13 @@
     /**
      * Get the client id as entered in the panel, without falling back to the defaults.
-     * @return the client id field's text
+     * @return the client id field's text, without surrounding white space
      * @since 19627
      */
     public String getEnteredClientId() {
-        return tfConsumerKey.getText();
+        return tfClientId.getText().trim();
     }
 
     protected boolean hasCustomSettings() {
-        IOAuthParameters params = OAuthParameters.createDefault(apiUrl, OAuthVersion.OAuth20);
+        IOAuthParameters params = OAuthParameters.createDefault(apiUrl, this.oauthVersion);
         return !params.equals(getAdvancedParameters());
     }
@@ -231,23 +311,33 @@
                         case OAuth21:
                             OAuth20Parameters params20 = (OAuth20Parameters) iParams;
-                            tfConsumerKey.setText(params20.getClientId());
-                            tfConsumerSecret.setText(params20.getClientSecret());
+                            tfClientId.setText(params20.getClientId());
+                            tfClientSecret.setText(params20.getClientSecret());
                             tfAccessTokenURL.setText(params20.getAccessTokenUrl());
                             tfAuthoriseURL.setText(params20.getAuthorizationUrl());
-                            tfRequestTokenURL.setText(params20.getRedirectUri());
+                            tfRedirectUri.setText(params20.getRedirectUri());
                             break;
                         default:
                             throw new UnsupportedOperationException("Unsupported OAuth version: " + this.oauthVersion);
                     }
-                    setChildComponentsEnabled(false);
+                    setChildComponentsVisible(false);
                 });
     }
 
-    protected void setChildComponentsEnabled(boolean enabled) {
+    /**
+     * Shows or hides the OAuth parameters: they are shown when the user enters them, that is when the default
+     * settings are not used. The access token is not one of them, and is always shown.
+     * @param visible {@code true} to show the parameters
+     * @since 19707
+     */
+    protected void setChildComponentsVisible(boolean visible) {
         for (Component c: getComponents()) {
+            if (c == tfAccessToken || c == lblAccessToken) {
+                continue;
+            }
             if (c instanceof JosmTextField || c instanceof JLabel) {
-                c.setEnabled(enabled);
-            }
-        }
+                c.setVisible(visible);
+            }
+        }
+        revalidate();
     }
 
@@ -260,11 +350,24 @@
         if (cbUseDefaults.isSelected())
             return OAuthParameters.createDefault(apiUrl, this.oauthVersion);
+        return getDisplayedParameters();
+    }
+
+    /**
+     * Replies the OAuth parameters as currently displayed in this properties panel: the default ones are shown when
+     * "use default settings" is ticked, as far as they are known yet. Unlike {@link #getAdvancedParameters()}, this
+     * never makes a network request, and some of the parameters may be empty. White space around the values, which
+     * is easily copied along with them, is left out: a client secret with a trailing space is refused by the server.
+     *
+     * @return the OAuth parameters
+     * @since 19707
+     */
+    public OAuth20Parameters getDisplayedParameters() {
         return new OAuth20Parameters(
-                tfConsumerKey.getText(),
-                tfConsumerSecret.getText(),
-                tfAccessTokenURL.getText(),
-                tfAuthoriseURL.getText(),
+                tfClientId.getText().trim(),
+                tfClientSecret.getText().trim(),
+                tfAccessTokenURL.getText().trim(),
+                tfAuthoriseURL.getText().trim(),
                 apiUrl,
-                tfRequestTokenURL.getText()
+                tfRedirectUri.getText().trim()
                 );
     }
@@ -280,15 +383,15 @@
         if (parameters.equals(OAuthParameters.createDefault(apiUrl, parameters.getOAuthVersion()))) {
             cbUseDefaults.setSelected(true);
-            setChildComponentsEnabled(false);
+            setChildComponentsVisible(false);
         } else {
             cbUseDefaults.setSelected(false);
-            setChildComponentsEnabled(true);
+            setChildComponentsVisible(true);
             if (parameters instanceof OAuth20Parameters) {
                 OAuth20Parameters parameters20 = (OAuth20Parameters) parameters;
-                tfConsumerKey.setText(parameters20.getClientId());
-                tfConsumerSecret.setText(parameters20.getClientSecret());
+                tfClientId.setText(parameters20.getClientId());
+                tfClientSecret.setText(parameters20.getClientSecret());
                 tfAccessTokenURL.setText(parameters20.getAccessTokenUrl());
                 tfAuthoriseURL.setText(parameters20.getAuthorizationUrl());
-                tfRequestTokenURL.setText(parameters20.getRedirectUri());
+                tfRedirectUri.setText(parameters20.getRedirectUri());
             }
         }
@@ -303,7 +406,10 @@
     public void initialize(String paramApiUrl) {
         CheckParameterUtil.ensureParameterNotNull(paramApiUrl, "paramApiUrl");
-        setApiUrl(paramApiUrl);
-        boolean useDefault = Config.getPref().getBoolean("oauth.settings.use-default", true);
+        this.apiUrl = paramApiUrl;
+        // "use default settings" is a setting of each server
+        boolean useDefault = OAuthParameters.isUseDefault(paramApiUrl);
         ilUseDefault.setEnabled(false);
+        cbUseDefaults.setSelected(useDefault);
+        setChildComponentsVisible(!useDefault);
         MainApplication.worker.execute(() -> {
             if (useDefault) {
@@ -311,5 +417,5 @@
             } else {
                 // createFromApiUrl may make a network request
-                final IOAuthParameters parameters = OAuthParameters.createFromApiUrl(paramApiUrl, OAuthVersion.OAuth20);
+                final IOAuthParameters parameters = OAuthParameters.createFromApiUrl(paramApiUrl, this.oauthVersion);
                 GuiHelper.runInEDT(() -> setAdvancedParameters(parameters));
             }
@@ -319,11 +425,14 @@
 
     /**
-     * Remembers the current values in the preferences <code>pref</code>.
+     * Remembers the current values in the preferences <code>pref</code>: whether the server uses the default
+     * settings, and the settings entered if not. Settings entered earlier are kept when the default settings are
+     * used, so that they are there again when they are needed again.
      */
     public void rememberPreferences() {
-        Config.getPref().putBoolean("oauth.settings.use-default", cbUseDefaults.isSelected());
-        if (cbUseDefaults.isSelected()) {
-            MainApplication.worker.execute(() -> OAuthParameters.createDefault().rememberPreferences());
-        } else {
+        if (apiUrl == null) {
+            return; // not initialized
+        }
+        OAuthParameters.setUseDefault(apiUrl, cbUseDefaults.isSelected());
+        if (!cbUseDefaults.isSelected()) {
             getAdvancedParameters().rememberPreferences();
         }
@@ -345,5 +454,5 @@
                 break;
             case ItemEvent.DESELECTED:
-                setChildComponentsEnabled(true);
+                setChildComponentsVisible(true);
                 break;
             default: // Do nothing
@@ -363,4 +472,10 @@
      */
     public void setApiUrl(String apiUrl) {
+        if (this.apiUrl != null && apiUrl != null
+                && !Objects.equals(OAuthParameters.getHost(this.apiUrl), OAuthParameters.getHost(apiUrl))) {
+            // another server, with settings of its own
+            initialize(apiUrl);
+            return;
+        }
         this.apiUrl = apiUrl;
         if (cbUseDefaults.isSelected()) {
Index: trunk/src/org/openstreetmap/josm/gui/oauth/AuthorizationProcedure.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/oauth/AuthorizationProcedure.java	(revision 19706)
+++ 	(revision )
@@ -1,76 +1,0 @@
-// License: GPL. For details, see LICENSE file.
-package org.openstreetmap.josm.gui.oauth;
-
-import static org.openstreetmap.josm.tools.I18n.tr;
-
-/**
- * The type of procedure to use for retrieving OAuth credentials.
- */
-public enum AuthorizationProcedure {
-    /**
-     * Run a fully automatic procedure to get an access token from the OSM website.
-     * JOSM accesses the OSM website on behalf of the JOSM user and interacts
-     * with the site using an OSM session, form posting and screen scraping.
-     */
-    FULLY_AUTOMATIC,
-
-    /**
-     * Run a semi-automatic procedure to get an access token from the OSM website.
-     * JOSM submits the standards OAuth requests to get a Request Token and an
-     * Access Token. It dispatches the user to the OSM website in an external browser
-     * to authenticate itself and to accept the request token submitted by JOSM.
-     */
-    SEMI_AUTOMATIC,
-
-    /**
-     * Enter an Access Token manually. The Access Token could have been generated
-     * by another JOSM user and sent to the current JOSM user via email, i.e. in order
-     * to grant the current OSM user the right download its private GPS traces. Or it could
-     * have been generated in a former session and filed away in a secure place.
-     */
-    MANUALLY;
-
-    /**
-     * Returns the translated name of this procedure
-     * @return the translated name of this procedure
-     */
-    public String getText() {
-        switch (this) {
-        case FULLY_AUTOMATIC:
-            return tr("Fully automatic");
-        case SEMI_AUTOMATIC:
-            return tr("Semi-automatic");
-        case MANUALLY:
-            return tr("Manual");
-        }
-        throw new IllegalStateException();
-    }
-
-    /**
-     * Returns a translated description of this procedure
-     * @return a translated description of this procedure
-     */
-    public String getDescription() {
-        switch (this) {
-        case FULLY_AUTOMATIC:
-            return tr(
-                    "<html>Run a fully automatic procedure to get an access token from the OSM website.<br>"
-                    + "JOSM accesses the OSM website on behalf of the JOSM user and fully<br>"
-                    + "automatically authorizes the user and retrieves an Access Token.</html>"
-            );
-        case SEMI_AUTOMATIC:
-            return tr(
-                    "<html>Run a semi-automatic procedure to get an access token from the OSM website.<br>"
-                    + "JOSM submits the standards OAuth requests to get a Request Token and an<br>"
-                    + "Access Token. It dispatches the user to the OSM website in an external browser<br>"
-                    + "to authenticate itself and to accept the request token submitted by JOSM.</html>"
-            );
-        case MANUALLY:
-            return tr(
-                    "<html>Enter an Access Token manually if it was generated and retrieved outside<br>"
-                    + "of JOSM.</html>"
-            );
-        }
-        throw new IllegalStateException();
-    }
-}
Index: trunk/src/org/openstreetmap/josm/gui/oauth/FullyAutomaticAuthorizationUI.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/oauth/FullyAutomaticAuthorizationUI.java	(revision 19706)
+++ 	(revision )
@@ -1,375 +1,0 @@
-// License: GPL. For details, see LICENSE file.
-package org.openstreetmap.josm.gui.oauth;
-
-import static org.openstreetmap.josm.tools.I18n.tr;
-
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.FlowLayout;
-import java.awt.Font;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.Insets;
-import java.awt.event.ActionEvent;
-import java.io.IOException;
-import java.util.concurrent.Executor;
-
-import javax.swing.AbstractAction;
-import javax.swing.BorderFactory;
-import javax.swing.JButton;
-import javax.swing.JLabel;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JTabbedPane;
-import javax.swing.text.html.HTMLEditorKit;
-
-import org.openstreetmap.josm.data.oauth.IOAuthToken;
-import org.openstreetmap.josm.data.oauth.OAuthVersion;
-import org.openstreetmap.josm.gui.HelpAwareOptionPane;
-import org.openstreetmap.josm.gui.PleaseWaitRunnable;
-import org.openstreetmap.josm.gui.help.HelpUtil;
-import org.openstreetmap.josm.gui.util.GuiHelper;
-import org.openstreetmap.josm.gui.widgets.HtmlPanel;
-import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
-import org.openstreetmap.josm.gui.widgets.VerticallyScrollablePanel;
-import org.openstreetmap.josm.io.OsmTransferException;
-import org.openstreetmap.josm.tools.ImageProvider;
-import org.openstreetmap.josm.tools.Logging;
-import org.xml.sax.SAXException;
-
-/**
- * This is a UI which supports a JOSM user to get an OAuth Access Token in a fully
- * automatic process.
- *
- * @since 2746
- */
-public class FullyAutomaticAuthorizationUI extends AbstractAuthorizationUI {
-    private final AccessTokenInfoPanel pnlAccessTokenInfo = new AccessTokenInfoPanel();
-    private OsmPrivilegesPanel pnlOsmPrivileges;
-    private JPanel pnlPropertiesPanel;
-    private JPanel pnlActionButtonsPanel;
-    private JPanel pnlResult;
-    private final transient Executor executor;
-
-    /**
-     * Builds the panel with the three privileges the user can grant JOSM
-     *
-     * @return constructed panel for the privileges
-     */
-    protected VerticallyScrollablePanel buildGrantsPanel() {
-        pnlOsmPrivileges = new OsmPrivilegesPanel();
-        return pnlOsmPrivileges;
-    }
-
-    /**
-     * Builds the panel for entering the username and password
-     *
-     * @return constructed panel for the credentials
-     */
-    protected VerticallyScrollablePanel buildUserNamePasswordPanel() {
-        VerticallyScrollablePanel pnl = new VerticallyScrollablePanel(new GridBagLayout());
-        GridBagConstraints gc = new GridBagConstraints();
-        pnl.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
-
-        gc.anchor = GridBagConstraints.NORTHWEST;
-        gc.fill = GridBagConstraints.HORIZONTAL;
-        gc.weightx = 1.0;
-        gc.gridwidth = 2;
-        HtmlPanel pnlMessage = new HtmlPanel();
-        HTMLEditorKit kit = (HTMLEditorKit) pnlMessage.getEditorPane().getEditorKit();
-        kit.getStyleSheet().addRule(
-                ".warning-body {background-color:#DDFFDD; padding: 10pt; " +
-                "border-color:rgb(128,128,128);border-style: solid;border-width: 1px;}");
-        kit.getStyleSheet().addRule("ol {margin-left: 1cm}");
-        pnlMessage.setText("<html><body><p class=\"warning-body\">"
-                + tr("Please enter your OSM user name and password. The password will <strong>not</strong> be saved "
-                        + "in clear text in the JOSM preferences and it will be submitted to the OSM server <strong>only once</strong>. "
-                        + "Subsequent data upload requests don''t use your password any more.").replace(". ", ".<br>")
-                        + "</p>"
-                        + "</body></html>");
-        pnl.add(pnlMessage, gc);
-
-        // the user name input field
-        gc.gridy = 1;
-        gc.gridwidth = 1;
-        gc.anchor = GridBagConstraints.NORTHWEST;
-        gc.fill = GridBagConstraints.HORIZONTAL;
-        gc.weightx = 0.0;
-        gc.insets = new Insets(0, 0, 3, 3);
-        pnl.add(new JLabel(tr("Username: ")), gc);
-
-        // the password input field
-        gc.anchor = GridBagConstraints.NORTHWEST;
-        gc.fill = GridBagConstraints.HORIZONTAL;
-        gc.gridy = 2;
-        gc.gridx = 0;
-        gc.weightx = 0.0;
-        pnl.add(new JLabel(tr("Password:")), gc);
-
-        // filler - grab remaining space
-        gc.gridx = 1;
-        gc.gridy = 4;
-        gc.gridwidth = 2;
-        gc.fill = GridBagConstraints.BOTH;
-        gc.weightx = 1.0;
-        gc.weighty = 1.0;
-        pnl.add(new JPanel(), gc);
-
-        return pnl;
-    }
-
-    protected JPanel buildPropertiesPanel() {
-        JPanel pnl = new JPanel(new BorderLayout());
-
-        JTabbedPane tpProperties = new JTabbedPane();
-        tpProperties.add(buildUserNamePasswordPanel().getVerticalScrollPane());
-        tpProperties.add(buildGrantsPanel().getVerticalScrollPane());
-        tpProperties.add(getAdvancedPropertiesPanel().getVerticalScrollPane());
-        tpProperties.setTitleAt(0, tr("Basic"));
-        tpProperties.setTitleAt(1, tr("Granted rights"));
-        tpProperties.setTitleAt(2, tr("Advanced OAuth properties"));
-
-        pnl.add(tpProperties, BorderLayout.CENTER);
-        return pnl;
-    }
-
-    /**
-     * Builds the panel with the action button  for starting the authorisation
-     *
-     * @return constructed button panel
-     */
-    protected JPanel buildActionButtonPanel() {
-        JPanel pnl = new JPanel(new FlowLayout(FlowLayout.LEFT));
-
-        RunAuthorisationAction runAuthorisationAction = new RunAuthorisationAction();
-        pnl.add(new JButton(runAuthorisationAction));
-        return pnl;
-    }
-
-    /**
-     * Builds the panel which displays the generated Access Token.
-     *
-     * @return constructed panel for the results
-     */
-    protected JPanel buildResultsPanel() {
-        JPanel pnl = new JPanel(new GridBagLayout());
-        GridBagConstraints gc = new GridBagConstraints();
-        pnl.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
-
-        // the message panel
-        gc.anchor = GridBagConstraints.NORTHWEST;
-        gc.fill = GridBagConstraints.HORIZONTAL;
-        gc.weightx = 1.0;
-        JMultilineLabel msg = new JMultilineLabel("");
-        msg.setFont(msg.getFont().deriveFont(Font.PLAIN));
-        String lbl = tr("Accept Access Token");
-        msg.setText(tr("<html>"
-                + "You have successfully retrieved an OAuth Access Token from the OSM website. "
-                + "Click on <strong>{0}</strong> to accept the token. JOSM will use it in "
-                + "subsequent requests to gain access to the OSM API."
-                + "</html>", lbl));
-        pnl.add(msg, gc);
-
-        // infos about the access token
-        gc.gridy = 1;
-        gc.insets = new Insets(5, 0, 0, 0);
-        pnl.add(pnlAccessTokenInfo, gc);
-
-        // the actions
-        JPanel pnl1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
-        pnl1.add(new JButton(new BackAction()));
-        pnl1.add(new JButton(new TestAccessTokenAction()));
-        gc.gridy = 2;
-        pnl.add(pnl1, gc);
-
-        // filler - grab the remaining space
-        gc.gridy = 3;
-        gc.fill = GridBagConstraints.BOTH;
-        gc.weightx = 1.0;
-        gc.weighty = 1.0;
-        pnl.add(new JPanel(), gc);
-
-        return pnl;
-    }
-
-    protected final void build() {
-        setLayout(new BorderLayout());
-        pnlPropertiesPanel = buildPropertiesPanel();
-        pnlActionButtonsPanel = buildActionButtonPanel();
-        pnlResult = buildResultsPanel();
-
-        prepareUIForEnteringRequest();
-    }
-
-    /**
-     * Prepares the UI for the first step in the automatic process: entering the authentication
-     * and authorisation parameters.
-     *
-     */
-    protected void prepareUIForEnteringRequest() {
-        removeAll();
-        add(pnlPropertiesPanel, BorderLayout.CENTER);
-        add(pnlActionButtonsPanel, BorderLayout.SOUTH);
-        pnlPropertiesPanel.revalidate();
-        pnlActionButtonsPanel.revalidate();
-        validate();
-        repaint();
-
-        setAccessToken(null);
-    }
-
-    /**
-     * Prepares the UI for the second step in the automatic process: displaying the access token
-     *
-     */
-    protected void prepareUIForResultDisplay() {
-        removeAll();
-        add(pnlResult, BorderLayout.CENTER);
-        validate();
-        repaint();
-    }
-
-    /**
-     * Constructs a new {@code FullyAutomaticAuthorizationUI} for the given API URL.
-     * @param apiUrl The OSM API URL
-     * @param executor the executor used for running the HTTP requests for the authorization
-     * @param oAuthVersion The OAuth version to use for this UI
-     * @since 18991
-     */
-    public FullyAutomaticAuthorizationUI(String apiUrl, Executor executor, OAuthVersion oAuthVersion) {
-        super(apiUrl, oAuthVersion);
-        this.executor = executor;
-        build();
-    }
-
-    @Override
-    public boolean isSaveAccessTokenToPreferences() {
-        return pnlAccessTokenInfo.isSaveToPreferences();
-    }
-
-    @Override
-    protected void setAccessToken(IOAuthToken accessToken) {
-        super.setAccessToken(accessToken);
-        pnlAccessTokenInfo.setAccessToken(accessToken);
-    }
-
-    /**
-     * Starts the authorisation process
-     */
-    class RunAuthorisationAction extends AbstractAction {
-        RunAuthorisationAction() {
-            putValue(NAME, tr("Authorize now"));
-            new ImageProvider("oauth", "oauth-small").getResource().attachImageIcon(this);
-            putValue(SHORT_DESCRIPTION, tr("Click to redirect you to the authorization form on the JOSM web site"));
-        }
-
-        @Override
-        public void actionPerformed(ActionEvent evt) {
-            executor.execute(new FullyAutomaticAuthorisationTask(FullyAutomaticAuthorizationUI.this));
-        }
-    }
-
-    /**
-     * Action to go back to step 1 in the process
-     */
-    class BackAction extends AbstractAction {
-        BackAction() {
-            putValue(NAME, tr("Back"));
-            putValue(SHORT_DESCRIPTION, tr("Run the automatic authorization steps again"));
-            new ImageProvider("dialogs", "previous").getResource().attachImageIcon(this);
-        }
-
-        @Override
-        public void actionPerformed(ActionEvent arg0) {
-            prepareUIForEnteringRequest();
-        }
-    }
-
-    /**
-     * Action to test an access token.
-     */
-    class TestAccessTokenAction extends AbstractAction {
-        TestAccessTokenAction() {
-            putValue(NAME, tr("Test Access Token"));
-            new ImageProvider("logo").getResource().attachImageIcon(this);
-        }
-
-        @Override
-        public void actionPerformed(ActionEvent arg0) {
-            executor.execute(new TestAccessTokenTask(
-                    FullyAutomaticAuthorizationUI.this,
-                    getApiUrl(),
-                    getAccessToken()
-            ));
-        }
-    }
-
-    class FullyAutomaticAuthorisationTask extends PleaseWaitRunnable {
-        private boolean canceled;
-
-        FullyAutomaticAuthorisationTask(Component parent) {
-            super(parent, tr("Authorize JOSM to access the OSM API"), false /* don't ignore exceptions */);
-        }
-
-        @Override
-        protected void cancel() {
-            canceled = true;
-        }
-
-        @Override
-        protected void finish() {
-            // Do nothing
-        }
-
-        protected void alertAuthorisationFailed() {
-            HelpAwareOptionPane.showOptionDialog(
-                    FullyAutomaticAuthorizationUI.this,
-                    tr("<html>"
-                            + "The automatic process for retrieving an OAuth Access Token<br>"
-                            + "from the OSM server failed.<br><br>"
-                            + "Please try again or choose another kind of authorization process,<br>"
-                            + "i.e. semi-automatic or manual authorization."
-                            +"</html>"),
-                    tr("OAuth authorization failed"),
-                    JOptionPane.ERROR_MESSAGE,
-                    HelpUtil.ht("/Dialog/OAuthAuthorisationWizard#FullyAutomaticProcessFailed")
-            );
-        }
-
-        protected void alertInvalidLoginUrl() {
-            HelpAwareOptionPane.showOptionDialog(
-                    FullyAutomaticAuthorizationUI.this,
-                    tr("<html>"
-                            + "The automatic process for retrieving an OAuth Access Token<br>"
-                            + "from the OSM server failed because JOSM was not able to build<br>"
-                            + "a valid login URL from the OAuth Authorize Endpoint URL ''{0}''.<br><br>"
-                            + "Please check your advanced setting and try again."
-                            + "</html>",
-                            getAdvancedPropertiesPanel().getAdvancedParameters().getAuthorizationUrl()),
-                    tr("OAuth authorization failed"),
-                    JOptionPane.ERROR_MESSAGE,
-                    HelpUtil.ht("/Dialog/OAuthAuthorisationWizard#FullyAutomaticProcessFailed")
-            );
-        }
-
-        protected void handleException(final OsmOAuthAuthorizationException e) {
-            Logging.error(e);
-            GuiHelper.runInEDT(this::alertAuthorisationFailed);
-        }
-
-        @Override
-        protected void realRun() throws SAXException, IOException, OsmTransferException {
-            getProgressMonitor().setTicksCount(2);
-            OAuthAuthorizationWizard.authorize(true, token -> {
-                if (!canceled) {
-                    getProgressMonitor().worked(1);
-                    GuiHelper.runInEDT(() -> {
-                        prepareUIForResultDisplay();
-                        setAccessToken(token.orElse(null));
-                    });
-                }
-            }, getApiUrl(), getOAuthVersion(), getOAuthParameters());
-            getProgressMonitor().worked(1);
-        }
-    }
-}
Index: trunk/src/org/openstreetmap/josm/gui/oauth/FullyAutomaticPropertiesPanel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/oauth/FullyAutomaticPropertiesPanel.java	(revision 19706)
+++ 	(revision )
@@ -1,80 +1,0 @@
-// License: GPL. For details, see LICENSE file.
-package org.openstreetmap.josm.gui.oauth;
-
-import static org.openstreetmap.josm.tools.I18n.tr;
-
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.Insets;
-
-import javax.swing.BorderFactory;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-
-import org.openstreetmap.josm.gui.preferences.server.UserNameValidator;
-import org.openstreetmap.josm.gui.widgets.JosmPasswordField;
-import org.openstreetmap.josm.gui.widgets.JosmTextField;
-import org.openstreetmap.josm.gui.widgets.SelectAllOnFocusGainedDecorator;
-
-/**
- * Panel to enter username and password for the "fully automatic" authorization
- * procedure.
- *
- * @see AuthorizationProcedure#FULLY_AUTOMATIC
- */
-public class FullyAutomaticPropertiesPanel extends JPanel {
-
-    private final JosmTextField tfUserName = new JosmTextField();
-    private final JosmPasswordField tfPassword = new JosmPasswordField();
-
-    /**
-     * Constructs a new {@code FullyAutomaticPropertiesPanel}.
-     */
-    public FullyAutomaticPropertiesPanel() {
-        setLayout(new GridBagLayout());
-        GridBagConstraints gc = new GridBagConstraints();
-        setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
-
-        gc.anchor = GridBagConstraints.NORTHWEST;
-        gc.fill = GridBagConstraints.HORIZONTAL;
-        gc.weightx = 1.0;
-        add(buildUserNamePasswordPanel(), gc);
-
-        gc.gridy = 1;
-        gc.weighty = 1.0;
-        gc.fill = GridBagConstraints.BOTH;
-        add(new JPanel(), gc);
-    }
-
-    protected final JPanel buildUserNamePasswordPanel() {
-        JPanel pnl = new JPanel(new GridBagLayout());
-        GridBagConstraints gc = new GridBagConstraints();
-
-        gc.anchor = GridBagConstraints.NORTHWEST;
-        gc.fill = GridBagConstraints.HORIZONTAL;
-        gc.weightx = 0.0;
-        gc.insets = new Insets(0, 0, 3, 3);
-        pnl.add(new JLabel(tr("Username: ")), gc);
-
-        gc.gridx = 1;
-        gc.weightx = 1.0;
-        pnl.add(tfUserName, gc);
-        SelectAllOnFocusGainedDecorator.decorate(tfUserName);
-        UserNameValidator valUserName = new UserNameValidator(tfUserName);
-        valUserName.validate();
-
-        gc.anchor = GridBagConstraints.NORTHWEST;
-        gc.fill = GridBagConstraints.HORIZONTAL;
-        gc.gridy = 1;
-        gc.gridx = 0;
-        gc.weightx = 0.0;
-        pnl.add(new JLabel(tr("Password:")), gc);
-
-        gc.gridx = 1;
-        gc.weightx = 1.0;
-        pnl.add(tfPassword, gc);
-        SelectAllOnFocusGainedDecorator.decorate(tfPassword);
-
-        return pnl;
-    }
-}
Index: trunk/src/org/openstreetmap/josm/gui/oauth/ManualAuthorizationUI.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/oauth/ManualAuthorizationUI.java	(revision 19706)
+++ 	(revision )
@@ -1,238 +1,0 @@
-// License: GPL. For details, see LICENSE file.
-package org.openstreetmap.josm.gui.oauth;
-
-import static org.openstreetmap.josm.tools.I18n.tr;
-
-import java.awt.BorderLayout;
-import java.awt.FlowLayout;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.Insets;
-import java.awt.event.ActionEvent;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.concurrent.Executor;
-
-import javax.swing.AbstractAction;
-import javax.swing.BorderFactory;
-import javax.swing.JButton;
-import javax.swing.JCheckBox;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JTabbedPane;
-import javax.swing.event.DocumentEvent;
-import javax.swing.event.DocumentListener;
-import javax.swing.text.JTextComponent;
-
-import org.openstreetmap.josm.data.oauth.OAuth20Exception;
-import org.openstreetmap.josm.data.oauth.OAuth20Token;
-import org.openstreetmap.josm.data.oauth.OAuthAccessTokenHolder;
-import org.openstreetmap.josm.data.oauth.OAuthVersion;
-import org.openstreetmap.josm.gui.widgets.DefaultTextComponentValidator;
-import org.openstreetmap.josm.gui.widgets.HtmlPanel;
-import org.openstreetmap.josm.gui.widgets.JosmTextField;
-import org.openstreetmap.josm.gui.widgets.SelectAllOnFocusGainedDecorator;
-import org.openstreetmap.josm.tools.ImageProvider;
-import org.openstreetmap.josm.tools.JosmRuntimeException;
-
-/**
- * This is an UI which supports a JOSM user to get an OAuth Access Token in a fully manual process.
- *
- * @since 2746
- */
-public class ManualAuthorizationUI extends AbstractAuthorizationUI {
-
-    private final JosmTextField tfAccessTokenKey = new JosmTextField();
-    private transient AccessTokenKeyValidator valAccessTokenKey;
-    private final JCheckBox cbSaveToPreferences = new JCheckBox(tr("Save Access Token in preferences"));
-    private final HtmlPanel pnlMessage = new HtmlPanel();
-    private final transient Executor executor;
-
-    /**
-     * Constructs a new {@code ManualAuthorizationUI} for the given API URL.
-     * @param apiUrl The OSM API URL
-     * @param executor the executor used for running the HTTP requests for the authorization
-     * @param oAuthVersion The OAuthVersion to use for this UI
-     * @since 18991
-     */
-    public ManualAuthorizationUI(String apiUrl, Executor executor, OAuthVersion oAuthVersion) {
-        super(null /* don't pass apiURL because setApiUrl is overridden and references a local field */,
-                oAuthVersion);
-        setApiUrl(apiUrl);
-        this.executor = executor;
-        build();
-    }
-
-    protected JPanel buildAccessTokenPanel() {
-        JPanel pnl = new JPanel(new GridBagLayout());
-        pnl.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
-        GridBagConstraints gc = new GridBagConstraints();
-        AccessTokenBuilder accessTokenBuilder = new AccessTokenBuilder();
-
-        // the access token key input field
-        gc.anchor = GridBagConstraints.NORTHWEST;
-        gc.fill = GridBagConstraints.HORIZONTAL;
-        gc.weightx = 0.0;
-        gc.gridwidth = 2;
-        gc.insets = new Insets(0, 0, 5, 0);
-        pnlMessage.setText("<html><body>"
-                + tr("Please enter an OAuth Access Token which is authorized to access the OSM server "
-                        + "''{0}''.",
-                        getApiUrl()) + "</body></html>");
-        pnl.add(pnlMessage, gc);
-
-        // the access token key input field
-        gc.gridy = 1;
-        gc.weightx = 0.0;
-        gc.gridwidth = 1;
-        gc.insets = new Insets(0, 0, 0, 3);
-        pnl.add(new JLabel(tr("Access Token Key:")), gc);
-
-        gc.gridx = 1;
-        gc.weightx = 1.0;
-        pnl.add(tfAccessTokenKey, gc);
-        SelectAllOnFocusGainedDecorator.decorate(tfAccessTokenKey);
-        valAccessTokenKey = new AccessTokenKeyValidator(tfAccessTokenKey);
-        valAccessTokenKey.validate();
-        tfAccessTokenKey.getDocument().addDocumentListener(accessTokenBuilder);
-
-        // the checkbox for saving to preferences
-        gc.gridy = 3;
-        gc.gridx = 0;
-        gc.gridwidth = 2;
-        gc.weightx = 1.0;
-        pnl.add(cbSaveToPreferences, gc);
-        cbSaveToPreferences.setSelected(OAuthAccessTokenHolder.getInstance().isSaveToPreferences());
-
-        // filler - grab remaining space
-        gc.gridy = 3;
-        gc.gridx = 0;
-        gc.gridwidth = 2;
-        gc.weightx = 1.0;
-        gc.weighty = 1.0;
-        gc.fill = GridBagConstraints.BOTH;
-        pnl.add(new JPanel(), gc);
-        return pnl;
-    }
-
-    protected JPanel buildTabbedPreferencesPanel() {
-        JPanel pnl = new JPanel(new BorderLayout());
-
-        JTabbedPane tp = new JTabbedPane();
-        tp.add(buildAccessTokenPanel());
-        tp.add(getAdvancedPropertiesPanel());
-
-        tp.setTitleAt(0, tr("Access Token"));
-        tp.setTitleAt(1, tr("Advanced OAuth parameters"));
-
-        tp.setToolTipTextAt(0, tr("Enter the OAuth Access Token"));
-        tp.setToolTipTextAt(1, tr("Enter advanced OAuth properties"));
-
-        pnl.add(tp, BorderLayout.CENTER);
-        return pnl;
-    }
-
-    protected JPanel buildActionsPanel() {
-        JPanel pnl = new JPanel(new FlowLayout(FlowLayout.LEFT));
-        TestAccessTokenAction actTestAccessToken = new TestAccessTokenAction();
-        pnl.add(new JButton(actTestAccessToken));
-        this.addPropertyChangeListener(actTestAccessToken);
-        return pnl;
-    }
-
-    @Override
-    public void setApiUrl(String apiUrl) {
-        super.setApiUrl(apiUrl);
-        if (pnlMessage != null) {
-            pnlMessage.setText(tr("<html><body>"
-                    + "Please enter an OAuth Access Token which is authorized to access the OSM server "
-                    + "''{0}''."
-                    + "</body></html>",
-                    getApiUrl()
-            ));
-        }
-    }
-
-    protected final void build() {
-        setLayout(new BorderLayout());
-        setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
-        add(buildTabbedPreferencesPanel(), BorderLayout.CENTER);
-        add(buildActionsPanel(), BorderLayout.SOUTH);
-    }
-
-    @Override
-    public boolean isSaveAccessTokenToPreferences() {
-        return cbSaveToPreferences.isSelected();
-    }
-
-    private static class AccessTokenKeyValidator extends DefaultTextComponentValidator {
-        AccessTokenKeyValidator(JTextComponent tc) {
-            super(tc, tr("Please enter an Access Token Key"),
-                      tr("The Access Token Key must not be empty. Please enter an Access Token Key"));
-        }
-    }
-
-    class AccessTokenBuilder implements DocumentListener {
-
-        public void build() {
-            if (!valAccessTokenKey.isValid()) {
-                setAccessToken(null);
-            } else {
-                try {
-                    setAccessToken(new OAuth20Token(getOAuthParameters(), "{\"token_type\":\"bearer\", \"access_token\":\""
-                            + tfAccessTokenKey.getText().trim() + "\"}"));
-                } catch (OAuth20Exception e) {
-                    throw new JosmRuntimeException(e);
-                }
-            }
-        }
-
-        @Override
-        public void changedUpdate(DocumentEvent e) {
-            build();
-        }
-
-        @Override
-        public void insertUpdate(DocumentEvent e) {
-            build();
-        }
-
-        @Override
-        public void removeUpdate(DocumentEvent e) {
-            build();
-        }
-    }
-
-    /**
-     * Action for testing an Access Token
-     */
-    class TestAccessTokenAction extends AbstractAction implements PropertyChangeListener {
-        TestAccessTokenAction() {
-            putValue(NAME, tr("Test Access Token"));
-            new ImageProvider("oauth", "oauth-small").getResource().attachImageIcon(this);
-            putValue(SHORT_DESCRIPTION, tr("Click to test the Access Token"));
-            updateEnabledState();
-        }
-
-        @Override
-        public void actionPerformed(ActionEvent evt) {
-            TestAccessTokenTask task = new TestAccessTokenTask(
-                    ManualAuthorizationUI.this,
-                    getApiUrl(),
-                    getAccessToken()
-            );
-            executor.execute(task);
-        }
-
-        protected final void updateEnabledState() {
-            setEnabled(hasAccessToken());
-        }
-
-        @Override
-        public void propertyChange(PropertyChangeEvent evt) {
-            if (!evt.getPropertyName().equals(AbstractAuthorizationUI.ACCESS_TOKEN_PROP))
-                return;
-            updateEnabledState();
-        }
-    }
-}
Index: trunk/src/org/openstreetmap/josm/gui/oauth/OAuthAuthorizationWizard.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/oauth/OAuthAuthorizationWizard.java	(revision 19706)
+++ 	(revision )
@@ -1,450 +1,0 @@
-// License: GPL. For details, see LICENSE file.
-package org.openstreetmap.josm.gui.oauth;
-
-import static org.openstreetmap.josm.tools.I18n.tr;
-
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.Dimension;
-import java.awt.FlowLayout;
-import java.awt.Font;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.ComponentAdapter;
-import java.awt.event.ComponentEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.lang.reflect.InvocationTargetException;
-import java.net.URL;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.concurrent.Executor;
-import java.util.concurrent.FutureTask;
-import java.util.function.Consumer;
-
-import javax.swing.AbstractAction;
-import javax.swing.BorderFactory;
-import javax.swing.JButton;
-import javax.swing.JDialog;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.SwingUtilities;
-import javax.swing.UIManager;
-import javax.swing.text.html.HTMLEditorKit;
-
-import org.openstreetmap.josm.data.oauth.IOAuthParameters;
-import org.openstreetmap.josm.data.oauth.IOAuthToken;
-import org.openstreetmap.josm.data.oauth.OAuth20Authorization;
-import org.openstreetmap.josm.data.oauth.OAuthAccessTokenHolder;
-import org.openstreetmap.josm.data.oauth.OAuthParameters;
-import org.openstreetmap.josm.data.oauth.OAuthVersion;
-import org.openstreetmap.josm.data.oauth.osm.OsmScopes;
-import org.openstreetmap.josm.gui.MainApplication;
-import org.openstreetmap.josm.gui.help.ContextSensitiveHelpAction;
-import org.openstreetmap.josm.gui.help.HelpUtil;
-import org.openstreetmap.josm.gui.util.GuiHelper;
-import org.openstreetmap.josm.gui.util.WindowGeometry;
-import org.openstreetmap.josm.gui.widgets.HtmlPanel;
-import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
-import org.openstreetmap.josm.io.auth.CredentialsManager;
-import org.openstreetmap.josm.io.remotecontrol.RemoteControl;
-import org.openstreetmap.josm.spi.preferences.Config;
-import org.openstreetmap.josm.tools.GBC;
-import org.openstreetmap.josm.tools.ImageProvider;
-import org.openstreetmap.josm.tools.InputMapUtils;
-import org.openstreetmap.josm.tools.UserCancelException;
-import org.openstreetmap.josm.tools.Utils;
-
-/**
- * This wizard walks the user to the necessary steps to retrieve an OAuth Access Token which
- * allows JOSM to access the OSM API on the users behalf.
- * @since 2746
- */
-public class OAuthAuthorizationWizard extends JDialog {
-    private boolean canceled;
-    private final AuthorizationProcedure procedure;
-    private final String apiUrl;
-    private final OAuthVersion oAuthVersion;
-
-    private FullyAutomaticAuthorizationUI pnlFullyAutomaticAuthorisationUI;
-    private ManualAuthorizationUI pnlManualAuthorisationUI;
-    private JScrollPane spAuthorisationProcedureUI;
-    private final transient Executor executor;
-
-    /**
-     * Launches the wizard, {@link OAuthAccessTokenHolder#setAccessToken(String, IOAuthToken)} sets the token
-     * and {@link OAuthAccessTokenHolder#setSaveToPreferences(boolean) saves to preferences}.
-     * @param callback Callback to run when authorization is finished
-     * @throws UserCancelException if user cancels the operation
-     */
-    public void showDialog(Consumer<Optional<IOAuthToken>> callback) throws UserCancelException {
-        if ((this.oAuthVersion == OAuthVersion.OAuth20 || this.oAuthVersion == OAuthVersion.OAuth21)
-        && this.procedure == AuthorizationProcedure.FULLY_AUTOMATIC) {
-            authorize(true, callback, this.apiUrl, this.oAuthVersion, getOAuthParameters());
-        } else {
-            setVisible(true);
-            if (isCanceled()) {
-                throw new UserCancelException();
-            }
-            OAuthAccessTokenHolder holder = OAuthAccessTokenHolder.getInstance();
-            holder.setAccessToken(apiUrl, getAccessToken());
-            holder.setSaveToPreferences(isSaveAccessTokenToPreferences());
-        }
-    }
-
-    /**
-     * Perform the oauth dance
-     *
-     * @param startRemoteControl {@code true} to start remote control if it is not already running
-     * @param callback           The callback to use to notify that the OAuth dance succeeded
-     * @param apiUrl             The API URL to get the token for
-     * @param oAuthVersion       The OAuth version that the authorization dance is force
-     * @param oAuthParameters    The OAuth parameters to use
-     */
-    static void authorize(boolean startRemoteControl, Consumer<Optional<IOAuthToken>> callback, String apiUrl,
-                          OAuthVersion oAuthVersion, IOAuthParameters oAuthParameters) {
-        final boolean remoteControlIsRunning = Boolean.TRUE.equals(RemoteControl.PROP_REMOTECONTROL_ENABLED.get());
-        // TODO: Ask user if they want to start remote control?
-        if (!remoteControlIsRunning && startRemoteControl) {
-            RemoteControl.start();
-        }
-        new OAuth20Authorization().authorize(
-                Optional.ofNullable(oAuthParameters).orElseGet(() -> OAuthParameters.createDefault(apiUrl, oAuthVersion)),
-                token -> {
-                    if (!remoteControlIsRunning) {
-                        RemoteControl.stop();
-                    }
-                    OAuthAccessTokenHolder.getInstance().setAccessToken(apiUrl, token.orElse(null));
-                    OAuthAccessTokenHolder.getInstance().save(CredentialsManager.getInstance());
-                    if (!token.isPresent()) {
-                        GuiHelper.runInEDT(() -> JOptionPane.showMessageDialog(MainApplication.getMainPanel(),
-                                tr("Authentication failed, please check browser for details."),
-                                tr("OAuth Authentication Failed"),
-                                JOptionPane.ERROR_MESSAGE));
-                    }
-                    if (callback != null) {
-                        callback.accept(token);
-                    }
-                }, OsmScopes.read_gpx, OsmScopes.write_gpx,
-                OsmScopes.read_prefs, OsmScopes.write_prefs,
-                OsmScopes.write_api, OsmScopes.write_notes);
-    }
-
-    /**
-     * Builds the row with the action buttons
-     *
-     * @return panel with buttons
-     */
-    protected JPanel buildButtonRow() {
-        JPanel pnl = new JPanel(new FlowLayout(FlowLayout.CENTER));
-
-        AcceptAccessTokenAction actAcceptAccessToken = new AcceptAccessTokenAction();
-        pnlFullyAutomaticAuthorisationUI.addPropertyChangeListener(actAcceptAccessToken);
-        pnlManualAuthorisationUI.addPropertyChangeListener(actAcceptAccessToken);
-
-        pnl.add(new JButton(actAcceptAccessToken));
-        pnl.add(new JButton(new CancelAction()));
-        pnl.add(new JButton(new ContextSensitiveHelpAction(HelpUtil.ht("/Dialog/OAuthAuthorisationWizard"))));
-
-        return pnl;
-    }
-
-    /**
-     * Builds the panel with general information in the header
-     *
-     * @return panel with information display
-     */
-    protected JPanel buildHeaderInfoPanel() {
-        JPanel pnl = new JPanel(new GridBagLayout());
-        pnl.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
-
-        // OAuth in a nutshell ...
-        HtmlPanel pnlMessage = new HtmlPanel();
-        pnlMessage.setText("<html><body>"
-                + tr("With OAuth you grant JOSM the right to upload map data and GPS tracks "
-                        + "on your behalf (<a href=\"{0}\">more info...</a>).", "https://wiki.openstreetmap.org/wiki/OAuth")
-                        + "</body></html>"
-        );
-        pnlMessage.enableClickableHyperlinks();
-        pnl.add(pnlMessage, GBC.eol().fill(GridBagConstraints.HORIZONTAL));
-
-        // the authorisation procedure
-        JMultilineLabel lbl = new JMultilineLabel(AuthorizationProcedure.FULLY_AUTOMATIC.getDescription());
-        lbl.setFont(lbl.getFont().deriveFont(Font.PLAIN));
-        pnl.add(lbl, GBC.eol());
-
-        if (!Config.getUrls().getDefaultOsmApiUrl().equals(apiUrl)) {
-            final HtmlPanel pnlWarning = new HtmlPanel();
-            final HTMLEditorKit kit = (HTMLEditorKit) pnlWarning.getEditorPane().getEditorKit();
-            kit.getStyleSheet().addRule(".warning-body {"
-                    + "background-color:rgb(253,255,221);padding: 10pt; "
-                    + "border-color:rgb(128,128,128);border-style: solid;border-width: 1px;}");
-            kit.getStyleSheet().addRule("ol {margin-left: 1cm}");
-            pnlWarning.setText("<html><body>"
-                    + "<p class=\"warning-body\">"
-                    + tr("<strong>Warning:</strong> Since you are using not the default OSM API, " +
-                    "make sure to set an OAuth consumer key and secret in the <i>Advanced OAuth parameters</i>.")
-                    + "</p>"
-                    + "</body></html>");
-            pnl.add(pnlWarning, GBC.eop().fill());
-        }
-
-        return pnl;
-    }
-
-    /**
-     * Refreshes the view of the authorisation panel, depending on the authorisation procedure
-     * currently selected
-     */
-    protected void refreshAuthorisationProcedurePanel() {
-        switch (procedure) {
-        case FULLY_AUTOMATIC:
-            spAuthorisationProcedureUI.getViewport().setView(pnlFullyAutomaticAuthorisationUI);
-            pnlFullyAutomaticAuthorisationUI.revalidate();
-            break;
-        case MANUALLY:
-            spAuthorisationProcedureUI.getViewport().setView(pnlManualAuthorisationUI);
-            pnlManualAuthorisationUI.revalidate();
-            break;
-        default:
-            throw new UnsupportedOperationException("Unsupported auth type: " + procedure);
-        }
-        validate();
-        repaint();
-    }
-
-    /**
-     * builds the UI
-     */
-    protected final void build() {
-        getContentPane().setLayout(new BorderLayout());
-        getContentPane().add(buildHeaderInfoPanel(), BorderLayout.NORTH);
-
-        setTitle(tr("Get an Access Token for ''{0}''", apiUrl));
-        this.setMinimumSize(new Dimension(500, 300));
-
-        pnlFullyAutomaticAuthorisationUI = new FullyAutomaticAuthorizationUI(apiUrl, executor, oAuthVersion);
-        pnlManualAuthorisationUI = new ManualAuthorizationUI(apiUrl, executor, oAuthVersion);
-
-        spAuthorisationProcedureUI = GuiHelper.embedInVerticalScrollPane(new JPanel());
-        spAuthorisationProcedureUI.getVerticalScrollBar().addComponentListener(
-                new ComponentAdapter() {
-                    @Override
-                    public void componentShown(ComponentEvent e) {
-                        spAuthorisationProcedureUI.setBorder(UIManager.getBorder("ScrollPane.border"));
-                    }
-
-                    @Override
-                    public void componentHidden(ComponentEvent e) {
-                        spAuthorisationProcedureUI.setBorder(null);
-                    }
-                }
-        );
-        getContentPane().add(spAuthorisationProcedureUI, BorderLayout.CENTER);
-        getContentPane().add(buildButtonRow(), BorderLayout.SOUTH);
-
-        addWindowListener(new WindowEventHandler());
-        InputMapUtils.addEscapeAction(getRootPane(), new CancelAction());
-
-        refreshAuthorisationProcedurePanel();
-
-        HelpUtil.setHelpContext(getRootPane(), HelpUtil.ht("/Dialog/OAuthAuthorisationWizard"));
-    }
-
-    /**
-     * Creates the wizard.
-     *
-     * @param parent             the component relative to which the dialog is displayed
-     * @param procedure          the authorization procedure to use
-     * @param apiUrl             the API URL. Must not be null.
-     * @param executor           the executor used for running the HTTP requests for the authorization
-     * @param oAuthVersion       The OAuth version this wizard is for
-     * @param advancedParameters The OAuth parameters to initialize the wizard with
-     * @throws IllegalArgumentException if apiUrl is null
-     */
-    public OAuthAuthorizationWizard(Component parent, AuthorizationProcedure procedure, String apiUrl,
-                                    Executor executor, OAuthVersion oAuthVersion, IOAuthParameters advancedParameters) {
-        super(GuiHelper.getFrameForComponent(parent), ModalityType.DOCUMENT_MODAL);
-        this.procedure = Objects.requireNonNull(procedure, "procedure");
-        this.apiUrl = Objects.requireNonNull(apiUrl, "apiUrl");
-        this.executor = executor;
-        this.oAuthVersion = oAuthVersion;
-        build();
-        if (advancedParameters != null) {
-            pnlFullyAutomaticAuthorisationUI.getAdvancedPropertiesPanel().setAdvancedParameters(advancedParameters);
-            pnlManualAuthorisationUI.getAdvancedPropertiesPanel().setAdvancedParameters(advancedParameters);
-        }
-    }
-
-    /**
-     * Replies true if the dialog was canceled
-     *
-     * @return true if the dialog was canceled
-     */
-    public boolean isCanceled() {
-        return canceled;
-    }
-
-    protected AbstractAuthorizationUI getCurrentAuthorisationUI() {
-        switch (procedure) {
-        case FULLY_AUTOMATIC: return pnlFullyAutomaticAuthorisationUI;
-        case MANUALLY: return pnlManualAuthorisationUI;
-        default: return null;
-        }
-    }
-
-    /**
-     * Replies the Access Token entered using the wizard
-     *
-     * @return the access token. May be null if the wizard was canceled.
-     */
-    public IOAuthToken getAccessToken() {
-        return getCurrentAuthorisationUI().getAccessToken();
-    }
-
-    /**
-     * Replies the current OAuth parameters.
-     *
-     * @return the current OAuth parameters.
-     */
-    public IOAuthParameters getOAuthParameters() {
-        return getCurrentAuthorisationUI().getOAuthParameters();
-    }
-
-    /**
-     * Replies true if the currently selected Access Token shall be saved to
-     * the preferences.
-     *
-     * @return true if the currently selected Access Token shall be saved to
-     * the preferences
-     */
-    public boolean isSaveAccessTokenToPreferences() {
-        return getCurrentAuthorisationUI().isSaveAccessTokenToPreferences();
-    }
-
-    /**
-     * Initializes the dialog with values from the preferences
-     *
-     */
-    public void initFromPreferences() {
-        pnlFullyAutomaticAuthorisationUI.initialize(apiUrl);
-        pnlManualAuthorisationUI.initialize(apiUrl);
-    }
-
-    @Override
-    public void setVisible(boolean visible) {
-        if (visible) {
-            pack();
-            new WindowGeometry(
-                    getClass().getName() + ".geometry",
-                    WindowGeometry.centerInWindow(
-                            MainApplication.getMainFrame(),
-                            getPreferredSize()
-                    )
-            ).applySafe(this);
-            initFromPreferences();
-        } else if (isShowing()) { // Avoid IllegalComponentStateException like in #8775
-            new WindowGeometry(this).remember(getClass().getName() + ".geometry");
-        }
-        super.setVisible(visible);
-    }
-
-    protected void setCanceled(boolean canceled) {
-        this.canceled = canceled;
-    }
-
-    /**
-     * Obtains an OAuth access token for the connection. Afterwards, the token is accessible via {@link OAuthAccessTokenHolder}.
-     * @param serverUrl the URL to OSM server
-     * @throws InterruptedException if we're interrupted while waiting for the event dispatching thread to finish OAuth authorization task
-     * @throws InvocationTargetException if an exception is thrown while running OAuth authorization task
-     * @since 12803
-     */
-    public static void obtainAccessToken(final URL serverUrl) throws InvocationTargetException, InterruptedException {
-        final Runnable authTask = new FutureTask<>(() -> {
-            // Concerning Utils.newDirectExecutor: Main worker cannot be used since this connection is already
-            // executed via main worker. The OAuth connections would block otherwise.
-            final OAuthAuthorizationWizard wizard = new OAuthAuthorizationWizard(
-                    MainApplication.getMainFrame(),
-                    AuthorizationProcedure.FULLY_AUTOMATIC,
-                    serverUrl.toString(), Utils.newDirectExecutor(),
-                    OAuthVersion.OAuth20, null);
-            wizard.showDialog(null);
-            return wizard;
-        });
-        // exception handling differs from implementation at GuiHelper.runInEDTAndWait()
-        if (SwingUtilities.isEventDispatchThread()) {
-            authTask.run();
-        } else {
-            SwingUtilities.invokeAndWait(authTask);
-        }
-    }
-
-    class CancelAction extends AbstractAction {
-
-        /**
-         * Constructs a new {@code CancelAction}.
-         */
-        CancelAction() {
-            putValue(NAME, tr("Cancel"));
-            new ImageProvider("cancel").getResource().attachImageIcon(this);
-            putValue(SHORT_DESCRIPTION, tr("Close the dialog and cancel authorization"));
-        }
-
-        public void cancel() {
-            setCanceled(true);
-            setVisible(false);
-        }
-
-        @Override
-        public void actionPerformed(ActionEvent evt) {
-            cancel();
-        }
-    }
-
-    class AcceptAccessTokenAction extends AbstractAction implements PropertyChangeListener {
-
-        /**
-         * Constructs a new {@code AcceptAccessTokenAction}.
-         */
-        AcceptAccessTokenAction() {
-            putValue(NAME, tr("Accept Access Token"));
-            new ImageProvider("ok").getResource().attachImageIcon(this);
-            putValue(SHORT_DESCRIPTION, tr("Close the dialog and accept the Access Token"));
-            updateEnabledState(null);
-        }
-
-        @Override
-        public void actionPerformed(ActionEvent evt) {
-            setCanceled(false);
-            setVisible(false);
-        }
-
-        /**
-         * Update the enabled state
-         * @param token The token to use
-         * @since 18991
-         */
-        public final void updateEnabledState(IOAuthToken token) {
-            setEnabled(token != null);
-        }
-
-        @Override
-        public void propertyChange(PropertyChangeEvent evt) {
-            if (!evt.getPropertyName().equals(AbstractAuthorizationUI.ACCESS_TOKEN_PROP))
-                return;
-            updateEnabledState((IOAuthToken) evt.getNewValue());
-        }
-    }
-
-    class WindowEventHandler extends WindowAdapter {
-        @Override
-        public void windowClosing(WindowEvent e) {
-            new CancelAction().cancel();
-        }
-    }
-}
Index: trunk/src/org/openstreetmap/josm/gui/oauth/OsmPrivilegesPanel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/oauth/OsmPrivilegesPanel.java	(revision 19706)
+++ 	(revision )
@@ -1,114 +1,0 @@
-// License: GPL. For details, see LICENSE file.
-package org.openstreetmap.josm.gui.oauth;
-
-import static org.openstreetmap.josm.tools.I18n.tr;
-
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.Insets;
-
-import javax.swing.BorderFactory;
-import javax.swing.JCheckBox;
-import javax.swing.JPanel;
-
-import org.openstreetmap.josm.data.oauth.OsmPrivileges;
-import org.openstreetmap.josm.gui.widgets.VerticallyScrollablePanel;
-
-/**
- * Panel letting the user choose from a detailed list of privileges that will be 
- * requested for the OAuth token.
- */
-public class OsmPrivilegesPanel extends VerticallyScrollablePanel {
-
-    private final JCheckBox cbWriteApi = new JCheckBox();
-    private final JCheckBox cbWriteGpx = new JCheckBox();
-    private final JCheckBox cbReadGpx = new JCheckBox();
-    private final JCheckBox cbWritePrefs = new JCheckBox();
-    private final JCheckBox cbReadPrefs = new JCheckBox();
-    private final JCheckBox cbModifyNotes = new JCheckBox();
-
-    /**
-     * Constructs a new {@code OsmPrivilegesPanel}.
-     */
-    public OsmPrivilegesPanel() {
-        build();
-    }
-
-    protected final void build() {
-        setLayout(new GridBagLayout());
-        GridBagConstraints gc = new GridBagConstraints();
-        setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
-
-        // checkbox for "allow to upload map data"
-        //
-        gc.anchor = GridBagConstraints.NORTHWEST;
-        gc.fill = GridBagConstraints.HORIZONTAL;
-        gc.weightx = 1.0;
-        gc.insets = new Insets(0, 0, 3, 3);
-        add(cbWriteApi, gc);
-        cbWriteApi.setText(tr("Allow to upload map data"));
-        cbWriteApi.setToolTipText(tr("Select to grant JOSM the right to upload map data on your behalf"));
-        cbWriteApi.setSelected(true);
-
-        // checkbox for "allow to upload gps traces"
-        //
-        gc.gridy = 1;
-        add(cbWriteGpx, gc);
-        cbWriteGpx.setText(tr("Allow to upload GPS traces"));
-        cbWriteGpx.setToolTipText(tr("Select to grant JOSM the right to upload GPS traces on your behalf"));
-        cbWriteGpx.setSelected(true);
-
-        // checkbox for "allow to download private gps traces"
-        //
-        gc.gridy = 2;
-        add(cbReadGpx, gc);
-        cbReadGpx.setText(tr("Allow to download your private GPS traces"));
-        cbReadGpx.setToolTipText(tr("Select to grant JOSM the right to download your private GPS traces into JOSM layers"));
-        cbReadGpx.setSelected(true);
-
-        // checkbox for "allow to download private gps traces"
-        //
-        gc.gridy = 3;
-        add(cbReadPrefs, gc);
-        cbReadPrefs.setText(tr("Allow to read your preferences"));
-        cbReadPrefs.setToolTipText(tr("Select to grant JOSM the right to read your server preferences"));
-        cbReadPrefs.setSelected(true);
-
-        // checkbox for "allow to download private gps traces"
-        //
-        gc.gridy = 4;
-        add(cbWritePrefs, gc);
-        cbWritePrefs.setText(tr("Allow to write your preferences"));
-        cbWritePrefs.setToolTipText(tr("Select to grant JOSM the right to write your server preferences"));
-        cbWritePrefs.setSelected(true);
-
-        gc.gridy = 5;
-        add(cbModifyNotes, gc);
-        cbModifyNotes.setText(tr("Allow modifications of notes"));
-        cbModifyNotes.setToolTipText(tr("Select to grant JOSM the right to modify notes on your behalf"));
-        cbModifyNotes.setSelected(true);
-
-        // filler - grab remaining space
-        gc.gridy = 6;
-        gc.fill = GridBagConstraints.BOTH;
-        gc.weightx = 1.0;
-        gc.weighty = 1.0;
-        add(new JPanel(), gc);
-    }
-
-    /**
-     * Replies the currently entered privileges
-     *
-     * @return the privileges
-     */
-    public OsmPrivileges getPrivileges() {
-        OsmPrivileges privileges = new OsmPrivileges();
-        privileges.setAllowWriteApi(cbWriteApi.isSelected());
-        privileges.setAllowWriteGpx(cbWriteGpx.isSelected());
-        privileges.setAllowReadGpx(cbReadGpx.isSelected());
-        privileges.setAllowWritePrefs(cbWritePrefs.isSelected());
-        privileges.setAllowReadPrefs(cbReadPrefs.isSelected());
-        privileges.setAllowModifyNotes(cbModifyNotes.isSelected());
-        return privileges;
-    }
-}
Index: trunk/src/org/openstreetmap/josm/gui/oauth/package-info.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/oauth/package-info.java	(revision 19706)
+++ trunk/src/org/openstreetmap/josm/gui/oauth/package-info.java	(revision 19707)
@@ -2,6 +2,5 @@
 
 /**
- * Provides GUI classes for handling OAuth authentication to OSM API.
- * Backend is <a href="https://github.com/mttkay/signpost">OAuth Signpost</a>.
+ * Provides GUI classes for handling OAuth 2.0 authentication to the OSM API.
  */
 package org.openstreetmap.josm.gui.oauth;
Index: trunk/src/org/openstreetmap/josm/gui/preferences/server/AuthenticationPreferencesPanel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/preferences/server/AuthenticationPreferencesPanel.java	(revision 19706)
+++ trunk/src/org/openstreetmap/josm/gui/preferences/server/AuthenticationPreferencesPanel.java	(revision 19707)
@@ -18,4 +18,5 @@
 import javax.swing.JRadioButton;
 
+import org.openstreetmap.josm.actions.ExpertToggleAction;
 import org.openstreetmap.josm.data.UserIdentityManager;
 import org.openstreetmap.josm.data.oauth.OAuthAccessTokenHolder;
@@ -36,4 +37,9 @@
 public class AuthenticationPreferencesPanel extends VerticallyScrollablePanel implements PropertyChangeListener {
 
+    /** the choice of the authentication method; only shown to experts, see {@link #updateAuthenticationMethodVisibility()} */
+    private final JPanel pnlAuthenticationMethod = new JPanel(new FlowLayout(FlowLayout.LEADING));
+    /** follows expert mode; held here since {@link ExpertToggleAction} only keeps a weak reference to its listeners */
+    private final transient ExpertToggleAction.ExpertModeChangeListener expertModeListener =
+            isExpert -> updateAuthenticationMethodVisibility();
     /** indicates whether we use basic authentication */
     private final JRadioButton rbBasicAuthentication = new JRadioButton();
@@ -64,12 +70,11 @@
         AuthenticationMethodChangeListener authChangeListener = new AuthenticationMethodChangeListener();
 
-        JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.LEADING));
         // -- radio button for basic authentication
-        buttonPanel.add(rbBasicAuthentication);
+        pnlAuthenticationMethod.add(rbBasicAuthentication);
         rbBasicAuthentication.setText(tr("Use Basic Authentication"));
         rbBasicAuthentication.setToolTipText(tr("Select to use HTTP basic authentication with your OSM username and password"));
         rbBasicAuthentication.addItemListener(authChangeListener);
         //-- radio button for OAuth 2.0
-        buttonPanel.add(rbOAuth20);
+        pnlAuthenticationMethod.add(rbOAuth20);
         rbOAuth20.setSelected(true); // This must before adding the listener; otherwise, saveToPreferences is called prior to initFromPreferences
         rbOAuth20.setText(tr("Use OAuth {0}", "2.0"));
@@ -77,5 +82,6 @@
         rbOAuth20.addItemListener(authChangeListener);
 
-        add(buttonPanel, GBC.eol());
+        add(pnlAuthenticationMethod, GBC.eol());
+        ExpertToggleAction.addExpertModeChangeListener(expertModeListener);
         //-- radio button for OAuth
         ButtonGroup bg = new ButtonGroup();
@@ -120,4 +126,15 @@
         pnlBasicAuthPreferences.initFromPreferences();
         pnlOAuth20Preferences.initFromPreferences();
+        updateAuthenticationMethodVisibility();
+    }
+
+    /**
+     * Shows the choice of the authentication method in expert mode only, since basic authentication is meant as a
+     * quick way to test one's own server rather than for normal use. It is shown regardless while basic
+     * authentication is selected, so that a profile using it does not lose sight of its own setting. Selecting
+     * another method does not hide the choice straight away, which would take the option away under the mouse.
+     */
+    private void updateAuthenticationMethodVisibility() {
+        pnlAuthenticationMethod.setVisible(ExpertToggleAction.isExpert() || rbBasicAuthentication.isSelected());
     }
 
@@ -133,5 +150,5 @@
             authMethod = "oauth20";
         } else {
-            throw new IllegalStateException("One of OAuth 2.0, OAuth 1.0a, or Basic authentication must be checked");
+            throw new IllegalStateException("One of OAuth 2.0 or Basic authentication must be checked");
         }
         final boolean initUser = Config.getPref().put("osm-server.auth-method", authMethod);
@@ -170,5 +187,5 @@
             } else if (rbOAuth20.isSelected()) {
                 pnlAuthenticationParameters.add(pnlOAuth20Preferences, BorderLayout.CENTER);
-                pnlOAuth20Preferences.saveToPreferences();
+                // only refresh it: saving here would save what was entered before the user pressed OK
                 pnlOAuth20Preferences.initFromPreferences();
                 pnlOAuth20Preferences.revalidate();
@@ -189,11 +206,22 @@
 
     /**
-     * Update the acceptable authentications methods
+     * Update the acceptable authentications methods: basic authentication is not offered for a server which is known
+     * not to accept it, unless it is in use already, so that it can be changed.
      * @param apiUrl The API url to check
      */
     private void updateAcceptableAuthenticationMethods(String apiUrl) {
         final String authMethod = OsmApi.getAuthMethod();
-        final boolean defaultApi = JosmUrls.getInstance().getDefaultOsmApiUrl().equals(apiUrl);
-        rbBasicAuthentication.setEnabled(rbBasicAuthentication.isSelected() || "basic".equals(authMethod) || !defaultApi);
+        rbBasicAuthentication.setEnabled(rbBasicAuthentication.isSelected() || "basic".equals(authMethod)
+                || !isOAuthOnly(apiUrl));
+    }
+
+    /**
+     * Determines whether a server is known to accept OAuth 2.0 only, not basic authentication.
+     * @param apiUrl The API url to check
+     * @return {@code true} for the default OSM API and the OpenGeofiction API
+     */
+    private static boolean isOAuthOnly(String apiUrl) {
+        final String url = OsmApi.normalizeApiUrl(apiUrl);
+        return JosmUrls.getInstance().getDefaultOsmApiUrl().equals(url) || "https://opengeofiction.net/api".equals(url);
     }
 
Index: trunk/src/org/openstreetmap/josm/gui/preferences/server/OAuthAuthenticationPreferencesPanel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/preferences/server/OAuthAuthenticationPreferencesPanel.java	(revision 19706)
+++ trunk/src/org/openstreetmap/josm/gui/preferences/server/OAuthAuthenticationPreferencesPanel.java	(revision 19707)
@@ -13,5 +13,4 @@
 import java.awt.Insets;
 import java.awt.event.ActionEvent;
-import java.awt.event.ItemEvent;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
@@ -19,5 +18,4 @@
 import java.net.URISyntaxException;
 import java.util.Arrays;
-import java.util.Objects;
 
 import javax.swing.AbstractAction;
@@ -25,41 +23,37 @@
 import javax.swing.JButton;
 import javax.swing.JCheckBox;
-import javax.swing.JLabel;
+import javax.swing.JOptionPane;
 import javax.swing.JPanel;
 
-import org.openstreetmap.josm.actions.ExpertToggleAction;
+import org.openstreetmap.josm.data.oauth.IOAuthParameters;
 import org.openstreetmap.josm.data.oauth.IOAuthToken;
+import org.openstreetmap.josm.data.oauth.OAuth20Authorization;
 import org.openstreetmap.josm.data.oauth.OAuth20Token;
 import org.openstreetmap.josm.data.oauth.OAuthAccessTokenHolder;
 import org.openstreetmap.josm.data.oauth.OAuthParameters;
 import org.openstreetmap.josm.data.oauth.OAuthVersion;
+import org.openstreetmap.josm.data.oauth.osm.OsmScopes;
 import org.openstreetmap.josm.data.validation.routines.DomainValidator;
 import org.openstreetmap.josm.gui.MainApplication;
 import org.openstreetmap.josm.gui.oauth.AdvancedOAuthPropertiesPanel;
-import org.openstreetmap.josm.gui.oauth.AuthorizationProcedure;
-import org.openstreetmap.josm.gui.oauth.OAuthAuthorizationWizard;
 import org.openstreetmap.josm.gui.oauth.TestAccessTokenTask;
 import org.openstreetmap.josm.gui.util.GuiHelper;
 import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
-import org.openstreetmap.josm.gui.widgets.JosmTextField;
 import org.openstreetmap.josm.io.OsmApi;
 import org.openstreetmap.josm.io.auth.CredentialsManager;
+import org.openstreetmap.josm.io.remotecontrol.RemoteControl;
 import org.openstreetmap.josm.tools.GBC;
 import org.openstreetmap.josm.tools.ImageProvider;
 import org.openstreetmap.josm.tools.Logging;
-import org.openstreetmap.josm.tools.UserCancelException;
 import org.openstreetmap.josm.tools.Utils;
 
 /**
- * The preferences panel for the OAuth 1.0a preferences. This just a summary panel
- * showing the current Access Token Key and Access Token Secret, if the
- * user already has an Access Token.
- * <br>
- * For initial authorisation see {@link OAuthAuthorizationWizard}.
+ * The preferences panel for OAuth 2.0: whether JOSM has an Access Token for the server, a button to authorize JOSM
+ * in the web browser, and the advanced OAuth parameters, which include the Access Token itself so that a token
+ * obtained outside JOSM can be pasted instead.
  * @since 2745
  */
 public class OAuthAuthenticationPreferencesPanel extends JPanel implements PropertyChangeListener {
     private final JCheckBox cbUseForAllRequests = new JCheckBox();
-    private final JCheckBox cbShowAdvancedParameters = new JCheckBox(tr("Display Advanced OAuth Parameters"));
     private final JCheckBox cbSaveToPreferences = new JCheckBox(tr("Save to preferences"));
     private final JPanel pnlAuthorisationMessage = new JPanel(new BorderLayout());
@@ -94,10 +88,4 @@
         cbUseForAllRequests.setToolTipText(tr("For user-based bandwidth limit instead of IP-based one"));
         pnl.add(cbUseForAllRequests, GBC.eol().fill(GBC.HORIZONTAL));
-
-        pnl.add(cbShowAdvancedParameters, GBC.eol().fill(GBC.HORIZONTAL));
-        cbShowAdvancedParameters.setSelected(false);
-        cbShowAdvancedParameters.addItemListener(
-                evt -> pnlAdvancedProperties.setVisible(evt.getStateChange() == ItemEvent.SELECTED)
-        );
 
         pnl.add(pnlAdvancedProperties, GBC.eol().fill(GBC.HORIZONTAL).insets(0, 3, 0, 0));
@@ -109,5 +97,4 @@
                 )
         );
-        pnlAdvancedProperties.setVisible(false);
         pnlAdvancedProperties.addPropertyChangeListener(this);
         return pnl;
@@ -119,5 +106,5 @@
      */
     private void updateAuthoriseNowActions() {
-        for (JPanel panel : Arrays.asList(this.pnlNotYetAuthorised, (JPanel) this.pnlAlreadyAuthorised.getComponent(6))) {
+        for (JPanel panel : Arrays.asList(this.pnlNotYetAuthorised, this.pnlAlreadyAuthorised.pnlButtons)) {
             for (Component component : panel.getComponents()) {
                 if (component instanceof JButton && ((JButton) component).getAction() instanceof AuthoriseNowAction) {
@@ -145,4 +132,5 @@
     protected void refreshView() {
         pnlAuthorisationMessage.removeAll();
+        pnlAdvancedProperties.setAccessToken(getBearerToken());
         if (OAuthAccessTokenHolder.getInstance().getAccessToken(this.apiUrl, this.oAuthVersion) != null) {
             pnlAuthorisationMessage.add(pnlAlreadyAuthorised, BorderLayout.CENTER);
@@ -157,4 +145,47 @@
 
     /**
+     * Get the bearer token JOSM currently has for the API.
+     * @return the bearer token, or {@code null} if there is none
+     */
+    private String getBearerToken() {
+        if (apiUrl == null) {
+            return null;
+        }
+        final IOAuthToken token = OAuthAccessTokenHolder.getInstance().getAccessToken(apiUrl, oAuthVersion);
+        return token instanceof OAuth20Token ? ((OAuth20Token) token).getBearerToken() : null;
+    }
+
+    /**
+     * Determines whether the user changed the access token in the advanced OAuth parameters.
+     * @return {@code true} if the access token entered differs from the one JOSM has
+     */
+    private boolean isAccessTokenEdited() {
+        final String current = getBearerToken();
+        return apiUrl != null && !pnlAdvancedProperties.getAccessToken().equals(current == null ? "" : current);
+    }
+
+    /**
+     * Get the access token entered in the advanced OAuth parameters: a token issued outside JOSM, pasted instead of
+     * authorizing JOSM. It works with nothing else, so it is a way to authenticate when authorizing JOSM is not
+     * possible.
+     * @return the token, or {@code null} if none is entered
+     */
+    private IOAuthToken getEnteredAccessToken() {
+        final String entered = pnlAdvancedProperties.getAccessToken();
+        return entered.isEmpty() ? null : OAuth20Token.fromAccessToken(pnlAdvancedProperties.getDisplayedParameters(), entered);
+    }
+
+    /**
+     * Takes over the access token entered in the advanced OAuth parameters, or removes the token if the field was
+     * cleared. This is done when the preferences are saved, so that cancelling them leaves the token as it was. A
+     * token which was not changed is left as it is, so that for example its refresh token is kept.
+     */
+    private void applyEnteredAccessToken() {
+        if (isAccessTokenEdited()) {
+            OAuthAccessTokenHolder.getInstance().setAccessToken(apiUrl, getEnteredAccessToken());
+        }
+    }
+
+    /**
      * Sets the URL of the OSM API for which this panel is currently displaying OAuth properties.
      *
@@ -180,4 +211,5 @@
      */
     public void saveToPreferences() {
+        applyEnteredAccessToken();
         OAuthAccessTokenHolder.getInstance().setSaveToPreferences(cbSaveToPreferences.isSelected());
         OAuthAccessTokenHolder.getInstance().save(CredentialsManager.getInstance());
@@ -209,8 +241,5 @@
 
             // Action for authorising now
-            add(new JButton(new AuthoriseNowAction(AuthorizationProcedure.FULLY_AUTOMATIC)), GBC.eol());
-            JButton authManually = new JButton(new AuthoriseNowAction(AuthorizationProcedure.MANUALLY));
-            add(authManually, GBC.eol());
-            ExpertToggleAction.addVisibilitySwitcher(authManually);
+            add(new JButton(new AuthoriseNowAction()), GBC.eol());
 
             // filler - grab remaining space
@@ -224,5 +253,5 @@
      */
     private class AlreadyAuthorisedPanel extends JPanel {
-        private final JosmTextField tfAccessTokenKey = new JosmTextField(null, null, 0, false);
+        private final JPanel pnlButtons = new JPanel(new FlowLayout(FlowLayout.LEFT));
 
         /**
@@ -246,25 +275,6 @@
             lbl.setFont(lbl.getFont().deriveFont(Font.PLAIN));
 
-            // -- access token key
+            // -- save to preferences; the Access Token itself is shown with the advanced OAuth parameters
             gc.gridy = 1;
-            gc.gridx = 0;
-            gc.gridwidth = 1;
-            gc.weightx = 0.0;
-            add(new JLabel(tr("Access Token Key:")), gc);
-
-            gc.gridx = 1;
-            gc.weightx = 1.0;
-            add(tfAccessTokenKey, gc);
-            tfAccessTokenKey.setEditable(false);
-
-            // -- access token secret
-            gc.gridy = 2;
-            gc.gridx = 0;
-            gc.gridwidth = 1;
-            gc.weightx = 0.0;
-            add(new JLabel(tr("Access Token Secret:")), gc);
-
-            // -- access token secret
-            gc.gridy = 3;
             gc.gridx = 0;
             gc.gridwidth = 2;
@@ -274,16 +284,15 @@
 
             // -- action buttons
-            JPanel btns = new JPanel(new FlowLayout(FlowLayout.LEFT));
-            btns.add(new JButton(new RenewAuthorisationAction(AuthorizationProcedure.FULLY_AUTOMATIC)));
-            btns.add(new JButton(new TestAuthorisationAction()));
-            btns.add(new JButton(new RemoveAuthorisationAction()));
-            gc.gridy = 4;
+            pnlButtons.add(new JButton(new RenewAuthorisationAction()));
+            pnlButtons.add(new JButton(new TestAuthorisationAction()));
+            pnlButtons.add(new JButton(new RemoveAuthorisationAction()));
+            gc.gridy = 2;
             gc.gridx = 0;
             gc.gridwidth = 2;
             gc.weightx = 1.0;
-            add(btns, gc);
+            add(pnlButtons, gc);
 
             // filler - grab the remaining space
-            gc.gridy = 6;
+            gc.gridy = 3;
             gc.fill = GridBagConstraints.BOTH;
             gc.weightx = 1.0;
@@ -293,16 +302,4 @@
 
         protected final void refreshView() {
-            switch (oAuthVersion) {
-                case OAuth20:
-                case OAuth21:
-                    String token = "";
-                    if (apiUrl != null) {
-                        OAuth20Token bearerToken = (OAuth20Token) OAuthAccessTokenHolder.getInstance().getAccessToken(apiUrl, oAuthVersion);
-                        token = bearerToken == null ? "" : bearerToken.getBearerToken();
-                    }
-                    tfAccessTokenKey.setText(token == null ? "" : token);
-                    break;
-                default:
-            }
             cbSaveToPreferences.setSelected(OAuthAccessTokenHolder.getInstance().isSaveToPreferences());
         }
@@ -310,25 +307,24 @@
 
     /**
-     * Action to authorise the current user
+     * Action to authorise the current user: JOSM is authorized in the web browser, with the OAuth parameters
+     * currently shown, and receives an Access Token by remote control.
      */
     private class AuthoriseNowAction extends AbstractAction {
-        private final AuthorizationProcedure procedure;
-
-        AuthoriseNowAction(AuthorizationProcedure procedure) {
-            this.procedure = procedure;
-            putValue(NAME, tr("{0} ({1})", tr("Authorize now"), procedure.getText()));
-            putValue(SHORT_DESCRIPTION, procedure.getDescription());
-            if (procedure == AuthorizationProcedure.FULLY_AUTOMATIC) {
-                new ImageProvider("oauth", "oauth-small").getResource().attachImageIcon(this);
-            }
+        /** Counts the updates of the enabled state, so that the result of an earlier one cannot override a later one */
+        private int updates;
+
+        AuthoriseNowAction() {
+            putValue(NAME, tr("Authorize now"));
+            putValue(SHORT_DESCRIPTION, tr("Authorize JOSM in the web browser to access the OSM server on your behalf, "
+                    + "and get an Access Token"));
+            new ImageProvider("oauth", "oauth-small").getResource().attachImageIcon(this);
             updateEnabledState();
         }
 
         void updateEnabledState() {
-            if (procedure == AuthorizationProcedure.MANUALLY) {
-                this.setEnabled(true);
-            } else if (!pnlAdvancedProperties.isUseDefaultSettings()) {
+            final int update = ++updates;
+            if (!pnlAdvancedProperties.isUseDefaultSettings()) {
                 // The user supplied the parameters - the client id of an OAuth application they
-                // registered on the server themselves. The wizard is given exactly these parameters
+                // registered on the server themselves. Authorization uses exactly these parameters
                 // when the button is pressed, so they decide whether it can be pressed.
                 this.setEnabled(!Utils.isEmpty(pnlAdvancedProperties.getEnteredClientId()));
@@ -342,11 +338,14 @@
                 }
                 if (DomainValidator.getInstance().isValid(apiURI.getHost())) {
-                    // We want to avoid trying to make connection with an invalid URL
+                    // We want to avoid trying to make connection with an invalid URL. These are the parameters
+                    // authorization uses, see AdvancedOAuthPropertiesPanel.getAdvancedParameters().
                     final String currentApiUrl = apiUrl;
                     MainApplication.worker.execute(() -> {
-                        final String clientId = OAuthParameters.createFromApiUrl(apiUrl, oAuthVersion).getClientId();
-                        if (Objects.equals(apiUrl, currentApiUrl)) {
-                            GuiHelper.runInEDT(() -> this.setEnabled(!Utils.isEmpty(clientId)));
-                        }
+                        final String clientId = OAuthParameters.createDefault(currentApiUrl, oAuthVersion).getClientId();
+                        GuiHelper.runInEDT(() -> {
+                            if (update == updates) {
+                                this.setEnabled(!Utils.isEmpty(clientId));
+                            }
+                        });
                     });
                 }
@@ -356,20 +355,30 @@
         @Override
         public void actionPerformed(ActionEvent arg0) {
-            OAuthAuthorizationWizard wizard = new OAuthAuthorizationWizard(
-                    OAuthAuthenticationPreferencesPanel.this,
-                    procedure,
-                    apiUrl,
-                    MainApplication.worker,
-                    oAuthVersion,
-                    pnlAdvancedProperties.getAdvancedParameters()
-                    );
-            try {
-                wizard.showDialog(token -> GuiHelper.runInEDT(OAuthAuthenticationPreferencesPanel.this::refreshView));
-            } catch (UserCancelException userCancelException) {
-                Logging.trace(userCancelException);
-                return;
+            final String currentApiUrl = apiUrl;
+            final IOAuthParameters parameters = pnlAdvancedProperties.getAdvancedParameters();
+            // the token is received by remote control, which is started for the time it takes if it is not running
+            final boolean remoteControlIsRunning = Boolean.TRUE.equals(RemoteControl.PROP_REMOTECONTROL_ENABLED.get());
+            if (!remoteControlIsRunning) {
+                RemoteControl.start();
             }
-            pnlAdvancedProperties.setAdvancedParameters(wizard.getOAuthParameters());
-            refreshView();
+            new OAuth20Authorization().authorize(parameters, token -> {
+                if (!remoteControlIsRunning) {
+                    RemoteControl.stop();
+                }
+                // a failed attempt, e.g. at a new token, leaves the token JOSM has as it is
+                token.ifPresent(t -> {
+                    OAuthAccessTokenHolder.getInstance().setAccessToken(currentApiUrl, t);
+                    OAuthAccessTokenHolder.getInstance().save(CredentialsManager.getInstance());
+                });
+                GuiHelper.runInEDT(() -> {
+                    if (!token.isPresent()) {
+                        JOptionPane.showMessageDialog(OAuthAuthenticationPreferencesPanel.this,
+                                tr("Authentication failed, please check browser for details."),
+                                tr("OAuth Authentication Failed"),
+                                JOptionPane.ERROR_MESSAGE);
+                    }
+                    refreshView();
+                });
+            }, OsmScopes.getJosmScopes());
         }
     }
@@ -394,5 +403,5 @@
 
     /**
-     * Launches the OAuthAuthorisationWizard to generate a new Access Token
+     * Authorizes JOSM again, to generate a new Access Token
      */
     private class RenewAuthorisationAction extends AuthoriseNowAction {
@@ -400,9 +409,7 @@
          * Constructs a new {@code RenewAuthorisationAction}.
          */
-        RenewAuthorisationAction(AuthorizationProcedure procedure) {
-            super(procedure);
+        RenewAuthorisationAction() {
             putValue(NAME, tr("New Access Token"));
             putValue(SHORT_DESCRIPTION, tr("Click to step through the OAuth authorization process and generate a new Access Token"));
-            new ImageProvider("oauth", "oauth-small").getResource().attachImageIcon(this);
         }
     }
@@ -423,5 +430,12 @@
         @Override
         public void actionPerformed(ActionEvent evt) {
-            IOAuthToken token = OAuthAccessTokenHolder.getInstance().getAccessToken(apiUrl, OAuthVersion.OAuth20);
+            // a token pasted but not saved yet is what the user wants to know about, and none if the field was cleared
+            final IOAuthToken token = isAccessTokenEdited() ? getEnteredAccessToken()
+                    : OAuthAccessTokenHolder.getInstance().getAccessToken(apiUrl, oAuthVersion);
+            if (token == null) {
+                JOptionPane.showMessageDialog(OAuthAuthenticationPreferencesPanel.this,
+                        tr("There is no Access Token to test."), tr("Test Access Token"), JOptionPane.INFORMATION_MESSAGE);
+                return;
+            }
             TestAccessTokenTask task = new TestAccessTokenTask(
                     OAuthAuthenticationPreferencesPanel.this,
@@ -437,6 +451,8 @@
         if (AdvancedOAuthPropertiesPanel.PARAMETERS_CHANGED_PROP.equals(evt.getPropertyName())) {
             updateAuthoriseNowActions();
+
         } else if (OsmApiUrlInputPanel.API_URL_PROP.equals(evt.getPropertyName())) {
             setApiUrl((String) evt.getNewValue());
+            refreshView();
         }
     }
Index: trunk/src/org/openstreetmap/josm/io/MissingOAuthAccessTokenException.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/MissingOAuthAccessTokenException.java	(revision 19706)
+++ trunk/src/org/openstreetmap/josm/io/MissingOAuthAccessTokenException.java	(revision 19707)
@@ -7,4 +7,7 @@
 public class MissingOAuthAccessTokenException extends OsmTransferException {
 
+    /** the API URL of the server JOSM has no OAuth client id for, so that it could not obtain an access token */
+    private final String clientIdMissingFor;
+
     /**
      * Constructs a new {@code MissingOAuthAccessTokenException}.
@@ -12,4 +15,5 @@
     public MissingOAuthAccessTokenException() {
         super();
+        this.clientIdMissingFor = null;
     }
 
@@ -22,4 +26,5 @@
     public MissingOAuthAccessTokenException(String message, Throwable cause) {
         super(message, cause);
+        this.clientIdMissingFor = null;
     }
 
@@ -30,4 +35,10 @@
     public MissingOAuthAccessTokenException(String message) {
         super(message);
+        this.clientIdMissingFor = null;
+    }
+
+    private MissingOAuthAccessTokenException(String message, String clientIdMissingFor) {
+        super(message);
+        this.clientIdMissingFor = clientIdMissingFor;
     }
 
@@ -39,4 +50,34 @@
     public MissingOAuthAccessTokenException(Throwable cause) {
         super(cause);
+        this.clientIdMissingFor = null;
+    }
+
+    /**
+     * Creates the exception for a server JOSM has no OAuth client id for, so that it cannot obtain an access token:
+     * the user has to enter the client id of an OAuth application registered on the server, or an access token.
+     * @param apiUrl the API URL of the server
+     * @return the exception
+     * @since 19707
+     */
+    public static MissingOAuthAccessTokenException clientIdMissing(String apiUrl) {
+        return new MissingOAuthAccessTokenException("No OAuth client id for " + apiUrl + ", cannot request a token", apiUrl);
+    }
+
+    /**
+     * Determines whether JOSM has no OAuth client id for the server, which is why it has no access token.
+     * @return {@code true} if the client id is missing
+     * @since 19707
+     */
+    public boolean isClientIdMissing() {
+        return clientIdMissingFor != null;
+    }
+
+    /**
+     * Get the API URL of the server JOSM has no OAuth client id for.
+     * @return the API URL, or {@code null} unless {@link #isClientIdMissing()}
+     * @since 19707
+     */
+    public String getClientIdMissingFor() {
+        return clientIdMissingFor;
     }
 }
Index: trunk/src/org/openstreetmap/josm/io/OsmConnection.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/OsmConnection.java	(revision 19706)
+++ trunk/src/org/openstreetmap/josm/io/OsmConnection.java	(revision 19707)
@@ -4,7 +4,5 @@
 import static org.openstreetmap.josm.tools.I18n.tr;
 
-import java.lang.reflect.InvocationTargetException;
 import java.net.Authenticator.RequestorType;
-import java.net.URL;
 import java.nio.charset.StandardCharsets;
 import java.util.Base64;
@@ -32,5 +30,4 @@
 import org.openstreetmap.josm.io.remotecontrol.RemoteControl;
 import org.openstreetmap.josm.tools.HttpClient;
-import org.openstreetmap.josm.tools.JosmRuntimeException;
 import org.openstreetmap.josm.tools.Logging;
 import org.openstreetmap.josm.tools.Utils;
@@ -49,32 +46,4 @@
     protected HttpClient activeConnection;
     protected IOAuthParameters oAuth20Parameters;
-
-    /**
-     * Retrieves OAuth access token.
-     * @since 12803
-     */
-    @FunctionalInterface
-    public interface OAuthAccessTokenFetcher {
-        /**
-         * Obtains an OAuth access token for the connection. Afterwards, the token is accessible via {@link OAuthAccessTokenHolder}.
-         * @param serverUrl the URL to OSM server
-         * @throws InterruptedException if we're interrupted while waiting for the event dispatching thread to finish OAuth authorization task
-         * @throws InvocationTargetException if an exception is thrown while running OAuth authorization task
-         */
-        void obtainAccessToken(URL serverUrl) throws InvocationTargetException, InterruptedException;
-    }
-
-    static volatile OAuthAccessTokenFetcher fetcher = u -> {
-        throw new JosmRuntimeException("OsmConnection.setOAuthAccessTokenFetcher() has not been called");
-    };
-
-    /**
-     * Sets the OAuth access token fetcher.
-     * @param tokenFetcher new OAuth access token fetcher. Cannot be null
-     * @since 12803
-     */
-    public static void setOAuthAccessTokenFetcher(OAuthAccessTokenFetcher tokenFetcher) {
-        fetcher = Objects.requireNonNull(tokenFetcher, "tokenFetcher");
-    }
 
     /**
@@ -150,9 +119,6 @@
         if (Utils.isEmpty(this.oAuth20Parameters.getClientId())) {
             // Without a client id the authorization request is rejected by the server with "Missing required
-            // parameter: client_id", so do not send the user to the browser at all. The message of the exception
-            // is for the log only; what the user is shown already points at the preferences, which is where the
-            // client id of an OAuth application registered on this server has to be entered.
-            throw new MissingOAuthAccessTokenException(
-                    "No OAuth client id for " + OsmApi.getOsmApi().getServerUrl() + ", cannot request a token");
+            // parameter: client_id", so do not send the user to the browser at all, but tell them what is missing.
+            throw MissingOAuthAccessTokenException.clientIdMissing(OsmApi.getOsmApi().getServerUrl());
         }
         if (!Boolean.TRUE.equals(GuiHelper.runInEDTAndWaitAndReturn(() ->
@@ -180,21 +146,15 @@
                 };
         new OAuth20Authorization().authorize(oAuth20Parameters,
-                consumer, OsmScopes.read_gpx, OsmScopes.write_gpx,
-                OsmScopes.read_prefs, OsmScopes.write_prefs,
-                OsmScopes.write_api, OsmScopes.write_notes);
-        // Only wait at most 5 minutes
-        int counter = 0;
-        while (done.getCount() >= 0 && counter < 5) {
-            try {
-                if (done.await(1, TimeUnit.MINUTES)) {
-                    break;
-                }
-            } catch (InterruptedException e) {
-                Thread.currentThread().interrupt();
-                Logging.trace(e);
-                consumer.accept(null);
-                throw new MissingOAuthAccessTokenException(e);
-            }
-            counter++;
+                consumer, OsmScopes.getJosmScopes());
+        // Only wait at most 5 minutes for the user to authorize JOSM in the web browser
+        try {
+            if (!done.await(5, TimeUnit.MINUTES)) {
+                Logging.warn("No OAuth access token received from {0} within 5 minutes", OsmApi.getOsmApi().getServerUrl());
+            }
+        } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
+            Logging.trace(e);
+            consumer.accept(Optional.empty());
+            throw new MissingOAuthAccessTokenException(e);
         }
     }
@@ -210,16 +170,16 @@
     protected void addOAuth20AuthorizationHeader(HttpClient connection) throws OsmTransferException {
         if (this.oAuth20Parameters == null) {
-            // The parameters are stored under the API URL, so look them up with the API URL and not with the
-            // host of the request: OAuthParameters.createFromApiUrl() reduces it to the host itself where that
-            // is what it needs.
+            // Look them up with the API URL and not with the host of the request: OAuthParameters.createFromApiUrl()
+            // reduces it to the host itself for the stored parameters, and needs the URL for the default ones.
             this.oAuth20Parameters = OAuthParameters.createFromApiUrl(OsmApi.getOsmApi().getServerUrl(), OAuthVersion.OAuth20);
         }
         OAuthAccessTokenHolder holder = OAuthAccessTokenHolder.getInstance();
         IOAuthToken token = holder.getAccessToken(connection.getURL().toExternalForm(), OAuthVersion.OAuth20);
-        if (token == null) {
+        // A token is obtained for the API, and so is only found for requests to the host of the API
+        if (token == null && Objects.equals(connection.getURL().getHost(), OsmApi.getOsmApi().getHost())) {
             obtainOAuth20Token();
             token = holder.getAccessToken(connection.getURL().toExternalForm(), OAuthVersion.OAuth20);
         }
-        if (token == null) { // check if wizard completed
+        if (token == null) { // check if authorization completed
             throw new MissingOAuthAccessTokenException();
         }
Index: trunk/src/org/openstreetmap/josm/io/auth/JosmPreferencesCredentialAgent.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/auth/JosmPreferencesCredentialAgent.java	(revision 19706)
+++ trunk/src/org/openstreetmap/josm/io/auth/JosmPreferencesCredentialAgent.java	(revision 19707)
@@ -133,13 +133,10 @@
             Set<String> keySet = new HashSet<>(Config.getPref().getKeySet());
             keySet.addAll(Config.getPref().getSensitive()); // Just in case we decide to not return sensitive keys in getKeySet
-            // Assume we want to remove all access tokens
+            // Assume we want to remove all access tokens. The parameters stay: they are also the OAuth settings the
+            // user entered for the server, which are needed to obtain the next token.
             for (OAuthVersion oauthType : OAuthVersion.values()) {
                 final String hostKey = "oauth.access-token.object." + oauthType + "." + host;
-                final String parametersKey = "oauth.access-token.parameters." + oauthType + "." + host;
                 if (keySet.contains(hostKey)) {
                     Config.getPref().removeSensitive(hostKey);
-                }
-                if (keySet.contains(parametersKey)) {
-                    Config.getPref().removeSensitive(parametersKey);
                 }
             }
@@ -147,8 +144,9 @@
             final String hostKey = "oauth.access-token.object." + accessToken.getOAuthType() + "." + host;
             final String parametersKey = "oauth.access-token.parameters." + accessToken.getOAuthType() + "." + host;
+            // the parameters first: listeners of the token, like UserIdentityManager, find them in place
+            Config.getPref().put(parametersKey, accessToken.getParameters().toPreferencesString());
+            Config.getPref().addSensitive(this, parametersKey);
             Config.getPref().put(hostKey, accessToken.toPreferencesString());
-            Config.getPref().put(parametersKey, accessToken.getParameters().toPreferencesString());
             Config.getPref().addSensitive(this, hostKey);
-            Config.getPref().addSensitive(this, parametersKey);
         }
     }
Index: trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java	(revision 19706)
+++ trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java	(revision 19707)
@@ -84,4 +84,14 @@
     public static String explainMissingOAuthAccessTokenException(MissingOAuthAccessTokenException e) {
         Logging.error(e);
+        if (e.isClientIdMissing()) {
+            return tr(
+                    "<html>Failed to authenticate at the OSM server ''{0}''.<br>"
+                    + "JOSM cannot obtain an OAuth Access Token for this server, because it has no OAuth Client ID for it.<br>"
+                    + "Please register an OAuth 2.0 application on the server, and enter its Client ID in the OAuth<br>"
+                    + "settings of the Preferences Dialog; or enter an Access Token obtained outside JOSM there."
+                    + "</html>",
+                    e.getClientIdMissingFor()
+            );
+        }
         return tr(
                 "<html>Failed to authenticate at the OSM server ''{0}''.<br>"
