diff --git a/src/org/openstreetmap/josm/gui/oauth/FullyAutomaticAuthorizationUI.java b/src/org/openstreetmap/josm/gui/oauth/FullyAutomaticAuthorizationUI.java
index d564184..ef1645f 100644
--- a/src/org/openstreetmap/josm/gui/oauth/FullyAutomaticAuthorizationUI.java
+++ b/src/org/openstreetmap/josm/gui/oauth/FullyAutomaticAuthorizationUI.java
@@ -14,6 +14,7 @@ import java.awt.event.ActionEvent;
 import java.io.IOException;
 import java.net.Authenticator.RequestorType;
 import java.net.PasswordAuthentication;
+import java.util.concurrent.Executor;
 
 import javax.swing.AbstractAction;
 import javax.swing.BorderFactory;
@@ -66,6 +67,7 @@ public class FullyAutomaticAuthorizationUI extends AbstractAuthorizationUI {
     private JPanel pnlPropertiesPanel;
     private JPanel pnlActionButtonsPanel;
     private JPanel pnlResult;
+    private final Executor executor;
 
     /**
      * Builds the panel with the three privileges the user can grant JOSM
@@ -314,10 +316,12 @@ public class FullyAutomaticAuthorizationUI extends AbstractAuthorizationUI {
     /**
      * 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
      * @since 5422
      */
-    public FullyAutomaticAuthorizationUI(String apiUrl) {
+    public FullyAutomaticAuthorizationUI(String apiUrl, Executor executor) {
         super(apiUrl);
+        this.executor = executor;
         build();
     }
 
@@ -345,7 +349,7 @@ public class FullyAutomaticAuthorizationUI extends AbstractAuthorizationUI {
 
         @Override
         public void actionPerformed(ActionEvent evt) {
-            Main.worker.submit(new FullyAutomaticAuthorisationTask(FullyAutomaticAuthorizationUI.this));
+            executor.execute(new FullyAutomaticAuthorisationTask(FullyAutomaticAuthorizationUI.this));
         }
 
         protected final void updateEnabledState() {
@@ -395,7 +399,7 @@ public class FullyAutomaticAuthorizationUI extends AbstractAuthorizationUI {
 
         @Override
         public void actionPerformed(ActionEvent arg0) {
-            Main.worker.submit(new TestAccessTokenTask(
+            executor.execute(new TestAccessTokenTask(
                     FullyAutomaticAuthorizationUI.this,
                     getApiUrl(),
                     getAdvancedPropertiesPanel().getAdvancedParameters(),
diff --git a/src/org/openstreetmap/josm/gui/oauth/ManualAuthorizationUI.java b/src/org/openstreetmap/josm/gui/oauth/ManualAuthorizationUI.java
index 63dc2a2..865aaee 100644
--- a/src/org/openstreetmap/josm/gui/oauth/ManualAuthorizationUI.java
+++ b/src/org/openstreetmap/josm/gui/oauth/ManualAuthorizationUI.java
@@ -11,6 +11,7 @@ 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;
@@ -22,7 +23,6 @@ import javax.swing.event.DocumentEvent;
 import javax.swing.event.DocumentListener;
 import javax.swing.text.JTextComponent;
 
-import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.oauth.OAuthToken;
 import org.openstreetmap.josm.gui.SideButton;
 import org.openstreetmap.josm.gui.preferences.server.OAuthAccessTokenHolder;
@@ -46,6 +46,7 @@ public class ManualAuthorizationUI extends AbstractAuthorizationUI {
     private transient AccessTokenSecretValidator valAccessTokenSecret;
     private JCheckBox cbSaveToPreferences;
     private HtmlPanel pnlMessage;
+    private final Executor executor;
 
     protected JPanel buildAccessTokenPanel() {
         JPanel pnl = new JPanel(new GridBagLayout());
@@ -162,10 +163,12 @@ public class ManualAuthorizationUI extends AbstractAuthorizationUI {
     /**
      * 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
      * @since 5422
      */
-    public ManualAuthorizationUI(String apiUrl) {
+    public ManualAuthorizationUI(String apiUrl, Executor executor) {
         super(apiUrl);
+        this.executor = executor;
         build();
     }
 
@@ -260,7 +263,7 @@ public class ManualAuthorizationUI extends AbstractAuthorizationUI {
                     getAdvancedPropertiesPanel().getAdvancedParameters(),
                     getAccessToken()
             );
-            Main.worker.submit(task);
+            executor.execute(task);
         }
 
         protected final void updateEnabledState() {
diff --git a/src/org/openstreetmap/josm/gui/oauth/OAuthAuthorizationWizard.java b/src/org/openstreetmap/josm/gui/oauth/OAuthAuthorizationWizard.java
index 2b44935..68d49cc 100644
--- a/src/org/openstreetmap/josm/gui/oauth/OAuthAuthorizationWizard.java
+++ b/src/org/openstreetmap/josm/gui/oauth/OAuthAuthorizationWizard.java
@@ -21,6 +21,7 @@ import java.awt.event.WindowAdapter;
 import java.awt.event.WindowEvent;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
+import java.util.concurrent.Executor;
 
 import javax.swing.AbstractAction;
 import javax.swing.BorderFactory;
@@ -43,11 +44,13 @@ import org.openstreetmap.josm.data.oauth.OAuthToken;
 import org.openstreetmap.josm.gui.SideButton;
 import org.openstreetmap.josm.gui.help.ContextSensitiveHelpAction;
 import org.openstreetmap.josm.gui.help.HelpUtil;
+import org.openstreetmap.josm.gui.preferences.server.OAuthAccessTokenHolder;
 import org.openstreetmap.josm.gui.util.GuiHelper;
 import org.openstreetmap.josm.gui.widgets.HtmlPanel;
 import org.openstreetmap.josm.tools.CheckParameterUtil;
 import org.openstreetmap.josm.tools.ImageProvider;
 import org.openstreetmap.josm.tools.OpenBrowser;
+import org.openstreetmap.josm.tools.UserCancelException;
 import org.openstreetmap.josm.tools.WindowGeometry;
 
 /**
@@ -64,6 +67,24 @@ public class OAuthAuthorizationWizard extends JDialog {
     private SemiAutomaticAuthorizationUI pnlSemiAutomaticAuthorisationUI;
     private ManualAuthorizationUI pnlManualAuthorisationUI;
     private JScrollPane spAuthorisationProcedureUI;
+    private final Executor executor;
+
+    /**
+     * Launches the wizard, {@link OAuthAccessTokenHolder#setAccessToken(OAuthToken) sets the token}
+     * and {@link OAuthAccessTokenHolder#setSaveToPreferences(boolean) saves to preferences}.
+     * @param saveAccessTokenToPreferences whether the retrieved token should be saved to preferences
+     *                                     (overrides {@link #isSaveAccessTokenToPreferences()})
+     * @throws UserCancelException if user cancels the operation
+     */
+    public void showDialog(final boolean saveAccessTokenToPreferences) throws UserCancelException {
+        setVisible(true);
+        if (isCanceled()) {
+            throw new UserCancelException();
+        }
+        OAuthAccessTokenHolder holder = OAuthAccessTokenHolder.getInstance();
+        holder.setAccessToken(getAccessToken());
+        holder.setSaveToPreferences(saveAccessTokenToPreferences || isSaveAccessTokenToPreferences());
+    }
 
     /**
      * Builds the row with the action buttons
@@ -169,9 +190,9 @@ public class OAuthAuthorizationWizard extends JDialog {
         setTitle(tr("Get an Access Token for ''{0}''", apiUrl));
         this.setMinimumSize(new Dimension(600, 420));
 
-        pnlFullyAutomaticAuthorisationUI = new FullyAutomaticAuthorizationUI(apiUrl);
-        pnlSemiAutomaticAuthorisationUI = new SemiAutomaticAuthorizationUI(apiUrl);
-        pnlManualAuthorisationUI = new ManualAuthorizationUI(apiUrl);
+        pnlFullyAutomaticAuthorisationUI = new FullyAutomaticAuthorizationUI(apiUrl, executor);
+        pnlSemiAutomaticAuthorisationUI = new SemiAutomaticAuthorizationUI(apiUrl, executor);
+        pnlManualAuthorisationUI = new ManualAuthorizationUI(apiUrl, executor);
 
         spAuthorisationProcedureUI = GuiHelper.embedInVerticalScrollPane(new JPanel());
         spAuthorisationProcedureUI.getVerticalScrollBar().addComponentListener(
@@ -208,24 +229,16 @@ public class OAuthAuthorizationWizard extends JDialog {
     /**
      * Creates the wizard.
      *
-     * @param apiUrl the API URL. Must not be null.
-     * @throws IllegalArgumentException if apiUrl is null
-     */
-    public OAuthAuthorizationWizard(String apiUrl) {
-        this(Main.parent, apiUrl);
-    }
-
-    /**
-     * Creates the wizard.
-     *
      * @param parent the component relative to which the dialog is displayed
      * @param apiUrl the API URL. Must not be null.
+     * @param executor the executor used for running the HTTP requests for the authorization
      * @throws IllegalArgumentException if apiUrl is null
      */
-    public OAuthAuthorizationWizard(Component parent, String apiUrl) {
+    public OAuthAuthorizationWizard(Component parent, String apiUrl, Executor executor) {
         super(JOptionPane.getFrameForComponent(parent), ModalityType.DOCUMENT_MODAL);
         CheckParameterUtil.ensureParameterNotNull(apiUrl, "apiUrl");
         this.apiUrl = apiUrl;
+        this.executor = executor;
         build();
     }
 
diff --git a/src/org/openstreetmap/josm/gui/oauth/SemiAutomaticAuthorizationUI.java b/src/org/openstreetmap/josm/gui/oauth/SemiAutomaticAuthorizationUI.java
index c8f3b74..ddc0aad 100644
--- a/src/org/openstreetmap/josm/gui/oauth/SemiAutomaticAuthorizationUI.java
+++ b/src/org/openstreetmap/josm/gui/oauth/SemiAutomaticAuthorizationUI.java
@@ -13,6 +13,7 @@ import java.awt.Insets;
 import java.awt.event.ActionEvent;
 import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
+import java.util.concurrent.Executor;
 
 import javax.swing.AbstractAction;
 import javax.swing.BorderFactory;
@@ -20,7 +21,6 @@ import javax.swing.JCheckBox;
 import javax.swing.JLabel;
 import javax.swing.JPanel;
 
-import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.oauth.OAuthToken;
 import org.openstreetmap.josm.gui.SideButton;
 import org.openstreetmap.josm.gui.preferences.server.OAuthAccessTokenHolder;
@@ -46,7 +46,8 @@ public class SemiAutomaticAuthorizationUI extends AbstractAuthorizationUI {
     private RetrieveRequestTokenPanel pnlRetrieveRequestToken;
     private RetrieveAccessTokenPanel pnlRetrieveAccessToken;
     private ShowAccessTokenPanel pnlShowAccessToken;
-
+    private final Executor executor;
+    
     /**
      * build the UI
      */
@@ -62,10 +63,12 @@ public class SemiAutomaticAuthorizationUI extends AbstractAuthorizationUI {
     /**
      * Constructs a new {@code SemiAutomaticAuthorizationUI} for the given API URL.
      * @param apiUrl The OSM API URL
+     * @param executor the executor used for running the HTTP requests for the authorization
      * @since 5422
      */
-    public SemiAutomaticAuthorizationUI(String apiUrl) {
+    public SemiAutomaticAuthorizationUI(String apiUrl, Executor executor) {
         super(apiUrl);
+        this.executor = executor;
         build();
     }
 
@@ -395,7 +398,7 @@ public class SemiAutomaticAuthorizationUI extends AbstractAuthorizationUI {
                     SemiAutomaticAuthorizationUI.this,
                     getAdvancedPropertiesPanel().getAdvancedParameters()
             );
-            Main.worker.submit(task);
+            executor.execute(task);
             Runnable r  = new Runnable() {
                 @Override
                 public void run() {
@@ -410,7 +413,7 @@ public class SemiAutomaticAuthorizationUI extends AbstractAuthorizationUI {
                     });
                 }
             };
-            Main.worker.submit(r);
+            executor.execute(r);
         }
     }
 
@@ -432,7 +435,7 @@ public class SemiAutomaticAuthorizationUI extends AbstractAuthorizationUI {
                     getAdvancedPropertiesPanel().getAdvancedParameters(),
                     requestToken
             );
-            Main.worker.submit(task);
+            executor.execute(task);
             Runnable r  = new Runnable() {
                 @Override
                 public void run() {
@@ -447,7 +450,7 @@ public class SemiAutomaticAuthorizationUI extends AbstractAuthorizationUI {
                     });
                 }
             };
-            Main.worker.submit(r);
+            executor.execute(r);
         }
     }
 
@@ -470,7 +473,7 @@ public class SemiAutomaticAuthorizationUI extends AbstractAuthorizationUI {
                     getAdvancedPropertiesPanel().getAdvancedParameters(),
                     getAccessToken()
             );
-            Main.worker.submit(task);
+            executor.execute(task);
         }
     }
 }
diff --git a/src/org/openstreetmap/josm/gui/preferences/server/AuthenticationPreferencesPanel.java b/src/org/openstreetmap/josm/gui/preferences/server/AuthenticationPreferencesPanel.java
index 308bbde..f5837fc 100644
--- a/src/org/openstreetmap/josm/gui/preferences/server/AuthenticationPreferencesPanel.java
+++ b/src/org/openstreetmap/josm/gui/preferences/server/AuthenticationPreferencesPanel.java
@@ -20,6 +20,7 @@ import javax.swing.JSeparator;
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.gui.help.HelpUtil;
 import org.openstreetmap.josm.gui.widgets.VerticallyScrollablePanel;
+import org.openstreetmap.josm.io.OsmApi;
 import org.openstreetmap.josm.io.auth.CredentialsManager;
 
 /**
@@ -117,7 +118,7 @@ public class AuthenticationPreferencesPanel extends VerticallyScrollablePanel im
      * Initializes the panel from preferences
      */
     public final void initFromPreferences() {
-        String authMethod = Main.pref.get("osm-server.auth-method", "basic");
+        final String authMethod = OsmApi.getAuthMethod();
         if ("basic".equals(authMethod)) {
             rbBasicAuthentication.setSelected(true);
         } else if ("oauth".equals(authMethod)) {
diff --git a/src/org/openstreetmap/josm/gui/preferences/server/OAuthAuthenticationPreferencesPanel.java b/src/org/openstreetmap/josm/gui/preferences/server/OAuthAuthenticationPreferencesPanel.java
index 6a7f553..cfd23b6 100644
--- a/src/org/openstreetmap/josm/gui/preferences/server/OAuthAuthenticationPreferencesPanel.java
+++ b/src/org/openstreetmap/josm/gui/preferences/server/OAuthAuthenticationPreferencesPanel.java
@@ -34,6 +34,7 @@ import org.openstreetmap.josm.gui.widgets.JosmTextField;
 import org.openstreetmap.josm.io.OsmApi;
 import org.openstreetmap.josm.io.auth.CredentialsManager;
 import org.openstreetmap.josm.tools.ImageProvider;
+import org.openstreetmap.josm.tools.UserCancelException;
 
 /**
  * The preferences panel for the OAuth preferences. This just a summary panel
@@ -324,13 +325,14 @@ public class OAuthAuthenticationPreferencesPanel extends JPanel implements Prope
         public void actionPerformed(ActionEvent arg0) {
             OAuthAuthorizationWizard wizard = new OAuthAuthorizationWizard(
                     OAuthAuthenticationPreferencesPanel.this,
-                    apiUrl
-            );
-            wizard.setVisible(true);
-            if (wizard.isCanceled()) return;
-            OAuthAccessTokenHolder holder = OAuthAccessTokenHolder.getInstance();
-            holder.setAccessToken(wizard.getAccessToken());
-            holder.setSaveToPreferences(wizard.isSaveAccessTokenToPreferences());
+                    apiUrl,
+                    Main.worker);
+            try {
+                wizard.showDialog(false);
+            } catch (UserCancelException ignore) {
+                Main.trace(ignore.toString());
+                return;
+            }
             pnlAdvancedProperties.setAdvancedParameters(wizard.getOAuthParameters());
             refreshView();
         }
@@ -339,7 +341,7 @@ public class OAuthAuthenticationPreferencesPanel extends JPanel implements Prope
     /**
      * Launches the OAuthAuthorisationWizard to generate a new Access Token
      */
-    private class RenewAuthorisationAction extends AbstractAction {
+    private class RenewAuthorisationAction extends AuthoriseNowAction {
         /**
          * Constructs a new {@code RenewAuthorisationAction}.
          */
@@ -347,22 +349,6 @@ public class OAuthAuthenticationPreferencesPanel extends JPanel implements Prope
             putValue(NAME, tr("New Access Token"));
             putValue(SHORT_DESCRIPTION, tr("Click to step through the OAuth authorization process and generate a new Access Token"));
             putValue(SMALL_ICON, ImageProvider.get("oauth", "oauth-small"));
-
-        }
-
-        @Override
-        public void actionPerformed(ActionEvent arg0) {
-            OAuthAuthorizationWizard wizard = new OAuthAuthorizationWizard(
-                    OAuthAuthenticationPreferencesPanel.this,
-                    apiUrl
-            );
-            wizard.setVisible(true);
-            if (wizard.isCanceled()) return;
-            OAuthAccessTokenHolder holder = OAuthAccessTokenHolder.getInstance();
-            holder.setAccessToken(wizard.getAccessToken());
-            holder.setSaveToPreferences(wizard.isSaveAccessTokenToPreferences());
-            pnlAdvancedProperties.setAdvancedParameters(wizard.getOAuthParameters());
-            refreshView();
         }
     }
 
diff --git a/src/org/openstreetmap/josm/io/OsmApi.java b/src/org/openstreetmap/josm/io/OsmApi.java
index be950e9..b3f93dd 100644
--- a/src/org/openstreetmap/josm/io/OsmApi.java
+++ b/src/org/openstreetmap/josm/io/OsmApi.java
@@ -581,8 +581,16 @@ public class OsmApi extends OsmConnection {
      * @return {@code true} if JOSM is configured to access OSM API via OAuth, {@code false} otherwise
      * @since 6349
      */
-    public static final boolean isUsingOAuth() {
-        return "oauth".equals(Main.pref.get("osm-server.auth-method", "basic"));
+    public static boolean isUsingOAuth() {
+        return "oauth".equals(getAuthMethod());
+    }
+
+    /**
+     * Returns the authentication method set in the preferences
+     * @return the authentication method
+     */
+    public static String getAuthMethod() {
+        return Main.pref.get("osm-server.auth-method", "oauth");
     }
 
     protected final String sendRequest(String requestMethod, String urlSuffix, String requestBody, ProgressMonitor monitor)
diff --git a/src/org/openstreetmap/josm/io/OsmConnection.java b/src/org/openstreetmap/josm/io/OsmConnection.java
index 7d690a9..5910083 100644
--- a/src/org/openstreetmap/josm/io/OsmConnection.java
+++ b/src/org/openstreetmap/josm/io/OsmConnection.java
@@ -3,15 +3,23 @@ package org.openstreetmap.josm.io;
 
 import static org.openstreetmap.josm.tools.I18n.tr;
 
+import java.lang.reflect.InvocationTargetException;
 import java.net.Authenticator.RequestorType;
+import java.net.MalformedURLException;
+import java.net.URL;
 import java.nio.ByteBuffer;
 import java.nio.CharBuffer;
 import java.nio.charset.CharacterCodingException;
 import java.nio.charset.CharsetEncoder;
 import java.nio.charset.StandardCharsets;
+import java.util.Objects;
+import java.util.concurrent.Callable;
+import java.util.concurrent.Executor;
+import java.util.concurrent.FutureTask;
 
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.oauth.OAuthParameters;
+import org.openstreetmap.josm.gui.oauth.OAuthAuthorizationWizard;
 import org.openstreetmap.josm.gui.preferences.server.OAuthAccessTokenHolder;
 import org.openstreetmap.josm.io.auth.CredentialsAgentException;
 import org.openstreetmap.josm.io.auth.CredentialsAgentResponse;
@@ -22,6 +30,8 @@ import org.openstreetmap.josm.tools.HttpClient;
 import oauth.signpost.OAuthConsumer;
 import oauth.signpost.exception.OAuthException;
 
+import javax.swing.SwingUtilities;
+
 /**
  * Base class that handles common things like authentication for the reader and writer
  * to the osm server.
@@ -95,8 +105,34 @@ public class OsmConnection {
         }
         OAuthConsumer consumer = oauthParameters.buildConsumer();
         OAuthAccessTokenHolder holder = OAuthAccessTokenHolder.getInstance();
-        if (!holder.containsAccessToken())
+        if (!holder.containsAccessToken()) {
+            try {
+                final URL apiUrl = new URL(Main.pref.get("osm-server.url", OsmApi.DEFAULT_API_URL));
+                if (!Objects.equals(apiUrl.getHost(), connection.getURL().getHost())) {
+                    throw new MissingOAuthAccessTokenException();
+                }
+                final FutureTask<OAuthAuthorizationWizard> authTask = new FutureTask<>(new Callable<OAuthAuthorizationWizard>() {
+                    @Override
+                    public OAuthAuthorizationWizard call() throws Exception {
+                        final OAuthAuthorizationWizard wizard = new OAuthAuthorizationWizard(
+                                Main.parent, apiUrl.toExternalForm(), new Executor() {
+                            @Override
+                            public void execute(Runnable command) {
+                                command.run();
+                            }
+                        });
+                        wizard.showDialog(true);
+                        return wizard;
+                    }
+                });
+                SwingUtilities.invokeAndWait(authTask);
+            } catch (MalformedURLException | InterruptedException | InvocationTargetException e) {
+                throw new MissingOAuthAccessTokenException();
+            }
+        }
+        if (!holder.containsAccessToken()) { // check if wizard completed
             throw new MissingOAuthAccessTokenException();
+        }
         consumer.setTokenWithSecret(holder.getAccessTokenKey(), holder.getAccessTokenSecret());
         try {
             consumer.sign(connection);
@@ -106,7 +142,7 @@ public class OsmConnection {
     }
 
     protected void addAuth(HttpClient connection) throws OsmTransferException {
-        String authMethod = Main.pref.get("osm-server.auth-method", "basic");
+        final String authMethod = OsmApi.getAuthMethod();
         if ("basic".equals(authMethod)) {
             addBasicAuthorizationHeader(connection);
         } else if ("oauth".equals(authMethod)) {
