Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java	(revision 31417)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java	(revision 31418)
@@ -68,86 +68,87 @@
    */
   public synchronized void add(List<MapillaryAbstractImage> images) {
+    add(images, true);
+  }
+
+  /**
+   * Adds an MapillaryImage to the object, and then repaints mapView.
+   *
+   * @param image
+   *          The image to be added.
+   */
+  public synchronized void add(MapillaryAbstractImage image) {
+    add(image, true);
+  }
+
+  /**
+   * Adds a new listener.
+   *
+   * @param lis
+   *          Listener to be added.
+   */
+  public void addListener(MapillaryDataListener lis) {
+    listeners.add(lis);
+  }
+
+  /**
+   * Removes a listener.
+   *
+   * @param lis
+   *          Listener to be removed.
+   */
+  public void removeListener(MapillaryDataListener lis) {
+    listeners.remove(lis);
+  }
+
+  /**
+   * Adds a set of MapillaryImages to the object, but doesn't repaint mapView.
+   * This is needed for concurrency.
+   *
+   * @param images
+   *          The set of images to be added.
+   * @param update
+   *          Whether the map must be updated or no.
+   */
+  public synchronized void add(List<MapillaryAbstractImage> images,
+      boolean update) {
     for (MapillaryAbstractImage image : images) {
-      add(image);
-    }
-  }
-
-  /**
-   * Adds an MapillaryImage to the object, and then repaints mapView.
+      add(image, update);
+    }
+  }
+
+  /**
+   * Highlights the image under the cursor.
+   *
+   * @param image
+   *          The image under the cursor.
+   */
+  public void setHighlightedImage(MapillaryAbstractImage image) {
+    highlightedImage = image;
+  }
+
+  /**
+   * Returns the image under the mouse cursor.
+   *
+   * @return The image under the mouse cursor.
+   */
+  public MapillaryAbstractImage getHighlighted() {
+    return highlightedImage;
+  }
+
+  /**
+   * Adds a MapillaryImage to the object, but doesn't repaint mapView. This is
+   * needed for concurrency.
    *
    * @param image
    *          The image to be added.
-   */
-  public synchronized void add(MapillaryAbstractImage image) {
+   * @param update
+   *          Whether the map must be updated or not.
+   */
+  public synchronized void add(MapillaryAbstractImage image, boolean update) {
     if (!images.contains(image)) {
       this.images.add(image);
     }
-    dataUpdated();
-    fireImagesAdded();
-  }
-
-  /**
-   * Adds a new listener.
-   *
-   * @param lis
-   *          Listener to be added.
-   */
-  public void addListener(MapillaryDataListener lis) {
-    listeners.add(lis);
-  }
-
-  /**
-   * Removes a listener.
-   *
-   * @param lis
-   *          Listener to be removed.
-   */
-  public void removeListener(MapillaryDataListener lis) {
-    listeners.remove(lis);
-  }
-
-  /**
-   * Adds a set of MapillaryImages to the object, but doesn't repaint mapView.
-   * This is needed for concurrency.
-   *
-   * @param images
-   *          The set of images to be added.
-   */
-  public synchronized void addWithoutUpdate(List<MapillaryAbstractImage> images) {
-    for (MapillaryAbstractImage image : images) {
-      addWithoutUpdate(image);
-    }
-  }
-
-  /**
-   * Highlights the image under the cursor.
-   *
-   * @param image
-   *          The image under the cursor.
-   */
-  public void setHighlightedImage(MapillaryAbstractImage image) {
-    highlightedImage = image;
-  }
-
-  /**
-   * Returns the image under the mouse cursor.
-   *
-   * @return The image under the mouse cursor.
-   */
-  public MapillaryAbstractImage getHighlighted() {
-    return highlightedImage;
-  }
-
-  /**
-   * Adds a MapillaryImage to the object, but doesn't repaint mapView. This is
-   * needed for concurrency.
-   *
-   * @param image
-   *          The image to be added.
-   */
-  public synchronized void addWithoutUpdate(MapillaryAbstractImage image) {
-    if (!images.contains(image)) {
-      this.images.add(image);
-    }
+    if (update)
+      dataUpdated();
     fireImagesAdded();
   }
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryPlugin.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryPlugin.java	(revision 31417)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryPlugin.java	(revision 31418)
@@ -52,4 +52,5 @@
   private final MapillaryDownloadAction downloadAction;
   private final MapillaryExportAction exportAction;
+  /** Import action */
   public static MapillaryImportAction importAction;
   private final MapillaryZoomAction zoomAction;
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportAction.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportAction.java	(revision 31417)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportAction.java	(revision 31418)
@@ -50,7 +50,8 @@
    */
   public MapillaryImportAction() {
-    super(tr("Import pictures"), new ImageProvider(MapillaryPlugin.directory + "images/icon24.png"),
-        tr("Import local pictures"), Shortcut.registerShortcut(
-            "Import Mapillary", tr("Import pictures into Mapillary layer"),
+    super(tr("Import pictures"), new ImageProvider(MapillaryPlugin.directory
+        + "images/icon24.png"), tr("Import local pictures"), Shortcut
+        .registerShortcut("Import Mapillary",
+            tr("Import pictures into Mapillary layer"),
             KeyEvent.CHAR_UNDEFINED, Shortcut.NONE), false, "mapillaryImport",
         false);
@@ -174,4 +175,21 @@
    */
   public MapillaryImportedImage readNoTags(File file) {
+    return readNoTags(
+        file,
+        Main.map.mapView.getProjection().eastNorth2latlon(
+            Main.map.mapView.getCenter()));
+  }
+
+  /**
+   * Reads a image file that doesn't contain the needed GPS information. And
+   * creates a new icon in the middle of the map.
+   *
+   * @param file
+   * @param pos
+   *          A {@link LatLon} object indicating the position in the map where
+   *          the image must be set.
+   * @return The imported image.
+   */
+  public MapillaryImportedImage readNoTags(File file, LatLon pos) {
     double HORIZONTAL_DISTANCE = 0.0001;
     double horDev;
@@ -180,6 +198,4 @@
     else
       horDev = -HORIZONTAL_DISTANCE * ((noTagsPics + 1) / 2);
-    LatLon pos = Main.map.mapView.getProjection().eastNorth2latlon(
-        Main.map.mapView.getCenter());
     noTagsPics++;
     return new MapillaryImportedImage(pos.lat(), pos.lon() + horDev, 0, file);
@@ -246,11 +262,4 @@
     result += degMinSec[2].doubleValue() / 3600; // seconds
 
-    while (result >= 180) {
-      result -= 180;
-    }
-    while (result <= -180) {
-      result += 180;
-    }
-
     if (GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF_VALUE_SOUTH.equals(ref)
         || GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF_VALUE_WEST.equals(ref)) {
@@ -258,4 +267,5 @@
     }
 
+    result = 360*((result+180)/360 - Math.floor((result+180)/360)) - 180;
     return result;
   }
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryDownloader.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryDownloader.java	(revision 31417)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryDownloader.java	(revision 31418)
@@ -33,5 +33,5 @@
   public final static String BASE_URL = "https://a.mapillary.com/v2/";
   /** Client ID for the app */
-  public final static String CLIENT_ID = "NzNRM2otQkR2SHJzaXJmNmdQWVQ0dzo1YTA2NmNlODhlNWMwOTBm";
+  public final static String CLIENT_ID = "T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz";
   /** Executor that will run the petitions. */
   private static ThreadPoolExecutor EXECUTOR = new ThreadPoolExecutor(3, 5,
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySequenceDownloadThread.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySequenceDownloadThread.java	(revision 31417)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySequenceDownloadThread.java	(revision 31418)
@@ -118,6 +118,6 @@
         }
 
-        layer.getMapillaryData().addWithoutUpdate(
-            new ArrayList<MapillaryAbstractImage>(finalImages));
+        layer.getMapillaryData().add(
+            new ArrayList<MapillaryAbstractImage>(finalImages), false);
       }
     } catch (IOException e) {
@@ -125,4 +125,5 @@
           + " might be a Mapillary problem.");
     }
+    layer.getMapillaryData().dataUpdated();
   }
 
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 31417)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryPreferenceSetting.java	(revision 31418)
@@ -84,5 +84,5 @@
       oauth.setText("Login");
     else
-      oauth.setText("Already loged in, click to relogin.");
+      oauth.setText("Logged as: " + Main.pref.get("mapillary.username") + ". Click to relogin.");
     panel.add(oauth);
     gui.getDisplayPreference().addSubTab(this, "Mapillary", panel);
@@ -130,5 +130,5 @@
       portListener.start();
 
-      String url = "http://www.mapillary.io/connect?redirect_uri=http:%2F%2Flocalhost:8763%2F&client_id=MkJKbDA0bnZuZlcxeTJHTmFqN3g1dzplZTlkZjQyYjYyZTczOTdi&response_type=token&scope=user:email";
+      String url = "http://www.mapillary.com/connect?redirect_uri=http:%2F%2Flocalhost:8763%2F&client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz&response_type=token&scope=user:read%20public:upload%20public:write";
       Desktop desktop = Desktop.getDesktop();
       if (desktop.isSupported(Desktop.Action.BROWSE)) {
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/OAuthPortListener.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/OAuthPortListener.java	(revision 31417)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/OAuthPortListener.java	(revision 31418)
@@ -8,4 +8,5 @@
 import java.net.ServerSocket;
 import java.net.Socket;
+import java.net.URL;
 import java.util.Scanner;
 
@@ -25,6 +26,8 @@
       ServerSocket serverSocket = new ServerSocket(8763);
       Socket clientSocket = serverSocket.accept();
-      PrintWriter out = new PrintWriter(new OutputStreamWriter(clientSocket.getOutputStream(), "UTF-8"), true);
-      Scanner in = new Scanner(new InputStreamReader(clientSocket.getInputStream(), "UTF-8"));
+      PrintWriter out = new PrintWriter(new OutputStreamWriter(
+          clientSocket.getOutputStream(), "UTF-8"), true);
+      Scanner in = new Scanner(new InputStreamReader(
+          clientSocket.getInputStream(), "UTF-8"));
       String s;
       String accessToken = null;
@@ -41,16 +44,30 @@
           }
           break;
-        }
+        } else if (s.contains("keep-alive"))
+          break;
       }
 
       writeContent(out);
 
-      Main.info("Successful login with Mapillary, the access token is: "
-          + accessToken);
-      Main.pref.put("mapillary.access-token", accessToken);
-
       out.close();
       in.close();
       serverSocket.close();
+
+      Main.info("Successful login with Mapillary, the access token is: "
+          + accessToken);
+      // Saves the access token in preferences.
+      Main.pref.put("mapillary.access-token", accessToken);
+      // Sets the logged username in preferences.
+      Main.pref
+          .put(
+              "mapillary.username",
+              OAuthUtils
+                  .getWithHeader(
+                      new URL(
+                          "https://a.mapillary.com/v2/me?client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz"))
+                  .getString("username"));
+
+      Main.info("The username is: " + Main.pref.get("mapillary.username"));
+
     } catch (BindException e) {
       return;
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/OAuthUtils.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/OAuthUtils.java	(revision 31418)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/OAuthUtils.java	(revision 31418)
@@ -0,0 +1,43 @@
+package org.openstreetmap.josm.plugins.mapillary.oauth;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import javax.json.Json;
+import javax.json.JsonObject;
+
+import org.openstreetmap.josm.Main;
+
+/**
+ * A set of utilities related to OAuth.
+ *
+ * @author nokutu
+ *
+ */
+public class OAuthUtils {
+
+  /** URL where to upload the images. */
+  public static final String MAPILLARY_UPLOAD_URL = "https://s3-eu-west-1.amazonaws.com/mapillary.uploads.manual.images";
+
+  /**
+   * Returns a JsonObject containing the result of making a GET request with the
+   * authorization header.
+   *
+   * @param url
+   * @return A JsonObject containing the result of the GET request.
+   * @throws IOException
+   */
+  public static JsonObject getWithHeader(URL url) throws IOException {
+    HttpURLConnection con = (HttpURLConnection) url.openConnection();
+    con.setRequestMethod("GET");
+    con.setRequestProperty("Authorization",
+        "Bearer " + Main.pref.get("mapillary.access-token"));
+
+    BufferedReader in = new BufferedReader(new InputStreamReader(
+        con.getInputStream()));
+    return Json.createReader(in).readObject();
+  }
+}
