Index: trunk/src/org/openstreetmap/josm/data/oauth/OAuth20Authorization.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/oauth/OAuth20Authorization.java	(revision 19139)
+++ trunk/src/org/openstreetmap/josm/data/oauth/OAuth20Authorization.java	(revision 19141)
@@ -4,4 +4,5 @@
 import static org.openstreetmap.josm.tools.I18n.tr;
 
+import java.awt.Dimension;
 import java.io.IOException;
 import java.net.MalformedURLException;
@@ -17,4 +18,11 @@
 import java.util.function.Consumer;
 
+import javax.swing.JOptionPane;
+import javax.swing.JScrollPane;
+
+import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils;
+import org.openstreetmap.josm.gui.util.GuiHelper;
+import org.openstreetmap.josm.gui.widgets.HtmlPanel;
 import org.openstreetmap.josm.io.remotecontrol.handler.AuthorizationHandler;
 import org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler;
@@ -56,5 +64,34 @@
                 + "&code_challenge_method=S256&code_challenge=" + s256CodeChallenge;
         AuthorizationHandler.addAuthorizationConsumer(state, new OAuth20AuthorizationHandler(state, codeVerifier, parameters, consumer));
-        OpenBrowser.displayUrl(url);
+        GuiHelper.runInEDT(() -> showUrlOpenFailure(url, OpenBrowser.displayUrl(url)));
+    }
+
+    /**
+     * Show a message if a URL fails to open
+     * @param url The URL that failed to open
+     * @param error The message indicating why the URL failed to open; if {@code null}, no message is shown.
+     */
+    private static void showUrlOpenFailure(String url, String error) {
+        if (error != null) {
+            final HtmlPanel textField = new HtmlPanel("<html><body>"
+                    + tr("The web browser failed to open with the following error: \"{0}\".<br>\n"
+                            + "Please open the following url:<br>\n"
+                            + "<a href=\"{1}\">{1}</a><br>\n"
+                            + "Should we copy the URL to the clipboard?", error, url)
+                    + "</body></html>");
+            textField.enableClickableHyperlinks();
+            final JScrollPane scrollPane = new JScrollPane(textField);
+            // Ensure that the scroll pane doesn't extend too much or too little.
+            // For now, assume that the user hasn't made the main JOSM frame beyond monitors.
+            scrollPane.setPreferredSize(new Dimension(Math.min(textField.getPreferredSize().width + 32,
+                    MainApplication.getMainFrame().getWidth() - 240 /* warning image + buffer */),
+                    textField.getPreferredSize().height + scrollPane.getHorizontalScrollBar().getPreferredSize().height * 2));
+            GuiHelper.prepareResizeableOptionPane(scrollPane, scrollPane.getPreferredSize());
+            int answer = JOptionPane.showConfirmDialog(MainApplication.getMainFrame(), scrollPane, tr("Failed to open browser"),
+                    JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE);
+            if (answer == JOptionPane.YES_OPTION) {
+                ClipboardUtils.copyString(url);
+            }
+        }
     }
 
