Index: /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryAbstractImage.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryAbstractImage.java	(revision 31389)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryAbstractImage.java	(revision 31390)
@@ -13,5 +13,5 @@
 /**
  * Abstract superclass for all image objects. At the moment there is just 2,
- * {@code MapillaryImportedImage} and {@code MapillaryImage}.
+ * {@link MapillaryImportedImage} and {@link MapillaryImage}.
  *
  * @author nokutu
Index: /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImportedImage.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImportedImage.java	(revision 31389)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImportedImage.java	(revision 31390)
@@ -95,8 +95,6 @@
   private static String currentDate() {
     Calendar cal = Calendar.getInstance();
-
     SimpleDateFormat formatter = new SimpleDateFormat("yyyy:MM:dd hh:mm:ss");
     return formatter.format(cal.getTime());
-
   }
 }
Index: /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/HyperlinkLabel.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/HyperlinkLabel.java	(revision 31389)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/HyperlinkLabel.java	(revision 31390)
@@ -109,4 +109,5 @@
   /**
    * Fires an ActionEvent to all interested listeners.
+   * @param evt 
    */
   protected void fireActionPerformed(ActionEvent evt) {
Index: plications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryOAuthUI.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryOAuthUI.java	(revision 31389)
+++ 	(revision )
@@ -1,50 +1,0 @@
-package org.openstreetmap.josm.plugins.mapillary.gui;
-
-import java.awt.Desktop;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-
-import org.openstreetmap.josm.plugins.mapillary.oauth.PortListener;
-
-/**
- * JPanel used to get the OAuth tokens from Mapillary.
- *
- * @author nokutu
- *
- */
-public class MapillaryOAuthUI extends JPanel {
-
-  private static final long serialVersionUID = 5882019193626545915L;
-
-  private PortListener portListener;
-  private JLabel text;
-
-  /**
-   * Main constructor.
-   */
-  public MapillaryOAuthUI() {
-    text = new JLabel("Authorize in browser");
-    this.add(text);
-    portListener = new PortListener(text);
-    portListener.start();
-
-    String url = "http://www.mapillary.io/connect?redirect_uri=http:%2F%2Flocalhost:8763%2F&client_id=MkJKbDA0bnZuZlcxeTJHTmFqN3g1dzplZTlkZjQyYjYyZTczOTdi&response_type=code&scope=user:email";
-    Desktop desktop = Desktop.getDesktop();
-    try {
-      desktop.browse(new URI(url));
-    } catch (IOException | URISyntaxException ex) {
-      ex.printStackTrace();
-    } catch (UnsupportedOperationException ex) {
-      Runtime runtime = Runtime.getRuntime();
-      try {
-        runtime.exec("xdg-open " + url);
-      } catch (IOException exc) {
-        exc.printStackTrace();
-      }
-    }
-  }
-}
Index: /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryPreferenceSetting.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryPreferenceSetting.java	(revision 31389)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryPreferenceSetting.java	(revision 31390)
@@ -3,12 +3,14 @@
 import static org.openstreetmap.josm.tools.I18n.tr;
 
+import java.awt.Desktop;
 import java.awt.FlowLayout;
 import java.awt.event.ActionEvent;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
 
 import javax.swing.AbstractAction;
 import javax.swing.JButton;
 import javax.swing.JCheckBox;
-import javax.swing.JDialog;
-import javax.swing.JOptionPane;
 import javax.swing.JPanel;
 
@@ -18,4 +20,5 @@
 import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;
 import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin;
+import org.openstreetmap.josm.plugins.mapillary.oauth.PortListener;
 
 /**
@@ -97,48 +100,21 @@
     @Override
     public void actionPerformed(ActionEvent arg0) {
-      JButton login = new JButton();
-      JButton cancel = new JButton();
-      JOptionPane pane = new JOptionPane(new MapillaryOAuthUI(),
-          JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION, null,
-          new JButton[] { login, cancel });
-      login.setAction(new LoginAction(pane));
-      cancel.setAction(new CancelAction(pane));
-      JDialog dlg = pane.createDialog(Main.parent, tr("Login"));
-      dlg.setVisible(true);
-      dlg.dispose();
-    }
-  }
+      PortListener portListener = new PortListener();
+      portListener.start();
 
-  private class LoginAction extends AbstractAction {
-
-    private static final long serialVersionUID = -7157028112711343289L;
-
-    private JOptionPane pane;
-
-    public LoginAction(JOptionPane pane) {
-      putValue(NAME, tr("Login"));
-      this.pane = pane;
-    }
-
-    @Override
-    public void actionPerformed(ActionEvent e) {
-      pane.setValue(JOptionPane.OK_OPTION);
-    }
-  }
-
-  private class CancelAction extends AbstractAction {
-
-    private static final long serialVersionUID = 2329066472975953270L;
-
-    private JOptionPane pane;
-
-    public CancelAction(JOptionPane pane) {
-      putValue(NAME, tr("Cancel"));
-      this.pane = pane;
-    }
-
-    @Override
-    public void actionPerformed(ActionEvent e) {
-      pane.setValue(JOptionPane.CANCEL_OPTION);
+      String url = "http://www.mapillary.io/connect?redirect_uri=http:%2F%2Flocalhost:8763%2F&client_id=MkJKbDA0bnZuZlcxeTJHTmFqN3g1dzplZTlkZjQyYjYyZTczOTdi&response_type=token&scope=user:email";
+      Desktop desktop = Desktop.getDesktop();
+      try {
+        desktop.browse(new URI(url));
+      } catch (IOException | URISyntaxException ex) {
+        ex.printStackTrace();
+      } catch (UnsupportedOperationException ex) {
+        Runtime runtime = Runtime.getRuntime();
+        try {
+          runtime.exec("xdg-open " + url);
+        } catch (IOException exc) {
+          exc.printStackTrace();
+        }
+      }
     }
   }
Index: plications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/MapillaryOAuthApi.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/MapillaryOAuthApi.java	(revision 31389)
+++ 	(revision )
@@ -1,29 +1,0 @@
-package org.openstreetmap.josm.plugins.mapillary.oauth;
-
-import org.scribe.builder.api.DefaultApi20;
-import org.scribe.model.OAuthConfig;
-import org.scribe.model.Verb;
-
-/**
- * API class of Mapillary for the scrable library.
- * 
- * @author nokutu
- *
- */
-public class MapillaryOAuthApi extends DefaultApi20 {
-
-  @Override
-  public String getAccessTokenEndpoint() {
-    return "https://a.mapillary.com/v2/oauth/token";
-  }
-
-  @Override
-  public String getAuthorizationUrl(OAuthConfig config) {
-    return "http://www.mapillary.io/connect?client_id=MkJKbDA0bnZuZlcxeTJHTmFqN3g1dzplZTlkZjQyYjYyZTczOTdi&redirect_uri=https:%2F%2Fjosm.openstreetmap.de%2F&response_type=token&scope=upload";
-  }
-
-  @Override
-  public Verb getAccessTokenVerb() {
-    return Verb.POST;
-  }
-}
Index: /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/PortListener.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/PortListener.java	(revision 31389)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/PortListener.java	(revision 31390)
@@ -8,7 +8,4 @@
 import java.util.Scanner;
 
-import javax.swing.JLabel;
-import javax.swing.SwingUtilities;
-
 import org.openstreetmap.josm.Main;
 
@@ -18,15 +15,4 @@
  */
 public class PortListener extends Thread {
-
-  JLabel text;
-
-  /**
-   * Main constructor.
-   *
-   * @param text
-   */
-  public PortListener(JLabel text) {
-    this.text = text;
-  }
 
   @Override
@@ -38,9 +24,15 @@
       Scanner in = new Scanner(new InputStreamReader(clientSocket.getInputStream()));
       String s;
-      String code = null;
+      String accessToken = null;
       while (in.hasNextLine()) {
         s = in.nextLine();
-        if (s.contains("?code=")) {
-          code = s.substring(s.indexOf("=") + 1, s.indexOf("HTTP") - 1);
+        if (s.contains("access_token=")) {
+          String[] ss = s.split("&");
+          for (int i = 0; i < ss.length; i++) {
+            if (ss[i].contains("access_token=")) {
+              accessToken = ss[i].substring(ss[i].indexOf("access_token=") + 13, ss[i].length());
+              break;
+            }
+          }
           break;
         }
@@ -49,5 +41,6 @@
       writeContent(out);
 
-      System.out.println("The code is: " + code);
+      Main.info("Successful login with Mapillary, the access token is: " + accessToken);
+      Main.pref.put("mapillary.access-token", accessToken);
 
       out.close();
@@ -57,18 +50,8 @@
       Main.error(e);
     }
-    if (!SwingUtilities.isEventDispatchThread()) {
-      SwingUtilities.invokeLater(new Runnable() {
-        @Override
-        public void run() {
-          text.setText("Authorization successful");
-        }
-      });
-    } else
-      text.setText("Authorization successful");
   }
 
   private void writeContent(PrintWriter out) {
-    String response = "";
-    response += "<html><body>Authorization successful</body></html>";
+    String response = "<html><head><title>Mapillary login</title></head><body>Login successful, return to JOSM.</body></html>";
     out.println("HTTP/1.1 200 OK");
     out.println("Content-Length: " + response.length());
