Index: trunk/src/org/openstreetmap/josm/data/oauth/OAuthAccessTokenHolder.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/oauth/OAuthAccessTokenHolder.java	(revision 18763)
+++ trunk/src/org/openstreetmap/josm/data/oauth/OAuthAccessTokenHolder.java	(revision 18764)
@@ -130,6 +130,8 @@
             IOAuthToken token = CredentialsManager.getInstance().lookupOAuthAccessToken(api);
             // We *do* want to set the API token to null, if it doesn't exist. Just to avoid unnecessary lookups.
-            this.setAccessToken(api, token);
-            return token;
+            if (token == null || token.getOAuthType() == version) {
+                this.setAccessToken(api, token);
+                return token;
+            }
         } catch (CredentialsAgentException exception) {
             Logging.trace(exception);
Index: trunk/src/org/openstreetmap/josm/gui/oauth/TestAccessTokenTask.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/oauth/TestAccessTokenTask.java	(revision 18763)
+++ trunk/src/org/openstreetmap/josm/gui/oauth/TestAccessTokenTask.java	(revision 18764)
@@ -12,4 +12,7 @@
 import javax.xml.parsers.ParserConfigurationException;
 
+import org.openstreetmap.josm.data.oauth.IOAuthParameters;
+import org.openstreetmap.josm.data.oauth.IOAuthToken;
+import org.openstreetmap.josm.data.oauth.OAuth20Token;
 import org.openstreetmap.josm.data.oauth.OAuthParameters;
 import org.openstreetmap.josm.data.oauth.OAuthToken;
@@ -42,6 +45,7 @@
  */
 public class TestAccessTokenTask extends PleaseWaitRunnable {
-    private final OAuthToken token;
-    private final OAuthParameters oauthParameters;
+    private final OAuthToken tokenOAuth1;
+    private final IOAuthToken tokenOAuth2;
+    private final IOAuthParameters oauthParameters;
     private boolean canceled;
     private final Component parent;
@@ -62,5 +66,27 @@
         CheckParameterUtil.ensureParameterNotNull(parameters, "parameters");
         CheckParameterUtil.ensureParameterNotNull(accessToken, "accessToken");
-        this.token = accessToken;
+        this.tokenOAuth1 = accessToken;
+        this.tokenOAuth2 = null;
+        this.oauthParameters = parameters;
+        this.parent = parent;
+        this.apiUrl = apiUrl;
+    }
+
+    /**
+     * Create the task
+     *
+     * @param parent the parent component relative to which the  {@link PleaseWaitRunnable}-Dialog is displayed
+     * @param apiUrl the API URL. Must not be null.
+     * @param parameters the OAuth parameters. Must not be null.
+     * @param accessToken the Access Token. Must not be null.
+     * @since xxx
+     */
+    public TestAccessTokenTask(Component parent, String apiUrl, IOAuthParameters parameters, IOAuthToken accessToken) {
+        super(parent, tr("Testing OAuth Access Token"), false /* don't ignore exceptions */);
+        CheckParameterUtil.ensureParameterNotNull(apiUrl, "apiUrl");
+        CheckParameterUtil.ensureParameterNotNull(parameters, "parameters");
+        CheckParameterUtil.ensureParameterNotNull(accessToken, "accessToken");
+        this.tokenOAuth1 = null;
+        this.tokenOAuth2 = accessToken;
         this.oauthParameters = parameters;
         this.parent = parent;
@@ -84,7 +110,16 @@
 
     protected void sign(HttpClient con) throws OAuthException {
-        OAuthConsumer consumer = oauthParameters.buildConsumer();
-        consumer.setTokenWithSecret(token.getKey(), token.getSecret());
-        consumer.sign(con);
+        if (oauthParameters instanceof OAuthParameters) {
+            OAuthConsumer consumer = ((OAuthParameters) oauthParameters).buildConsumer();
+            consumer.setTokenWithSecret(tokenOAuth1.getKey(), tokenOAuth1.getSecret());
+            consumer.sign(con);
+        } else {
+            try {
+                this.tokenOAuth2.sign(con);
+            } catch (org.openstreetmap.josm.data.oauth.OAuthException e) {
+                // Adapt our OAuthException to the SignPost OAuth exception
+                throw new OAuthException(e) {};
+            }
+        }
     }
 
@@ -114,11 +149,13 @@
             }
 
+            final String oauthKey = getAuthKey();
             if (connection.getResponse().getResponseCode() == HttpURLConnection.HTTP_UNAUTHORIZED)
                 throw new OsmApiException(HttpURLConnection.HTTP_UNAUTHORIZED,
-                        tr("Retrieving user details with Access Token Key ''{0}'' was rejected.", token.getKey()), null);
+                        tr("Retrieving user details with Access Token Key ''{0}'' was rejected.",
+                                oauthKey), null);
 
             if (connection.getResponse().getResponseCode() == HttpURLConnection.HTTP_FORBIDDEN)
                 throw new OsmApiException(HttpURLConnection.HTTP_FORBIDDEN,
-                        tr("Retrieving user details with Access Token Key ''{0}'' was forbidden.", token.getKey()), null);
+                        tr("Retrieving user details with Access Token Key ''{0}'' was forbidden.", oauthKey), null);
 
             if (connection.getResponse().getResponseCode() != HttpURLConnection.HTTP_OK)
@@ -146,5 +183,5 @@
                         + "You are accessing the OSM server as user ''{2}'' with id ''{3}''."
                         + "</html>",
-                        token.getKey(),
+                        getAuthKey(),
                         apiUrl,
                         Utils.escapeReservedCharactersHTML(userInfo.getDisplayName()),
@@ -167,5 +204,5 @@
                         +"</html>",
                         apiUrl,
-                        token.getKey()
+                        getAuthKey()
                 ),
                 tr("Test failed"),
@@ -185,5 +222,5 @@
                         +"</html>",
                         apiUrl,
-                        token.getKey()
+                        getAuthKey()
                 ),
                 tr("Token allows restricted access"),
@@ -204,5 +241,5 @@
                         +"</html>",
                         apiUrl,
-                        token.getKey()
+                        getAuthKey()
                 ),
                 tr("Test failed"),
@@ -221,5 +258,5 @@
                         +"</html>",
                         apiUrl,
-                        token.getKey()
+                        getAuthKey()
                 ),
                 tr("Test failed"),
@@ -237,5 +274,5 @@
                         + "</html>",
                         apiUrl,
-                        token.getKey()
+                        getAuthKey()
                 ),
                 tr("Test failed"),
@@ -276,3 +313,13 @@
         }
     }
+
+    private String getAuthKey() {
+        if (this.tokenOAuth1 != null) {
+            return this.tokenOAuth1.getKey();
+        }
+        if (this.tokenOAuth2 instanceof OAuth20Token) {
+            return ((OAuth20Token) this.tokenOAuth2).getBearerToken();
+        }
+        throw new IllegalArgumentException("Only OAuth1 and OAuth2 tokens are understood: " + this.tokenOAuth2);
+    }
 }
Index: trunk/src/org/openstreetmap/josm/gui/preferences/server/AuthenticationPreferencesPanel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/preferences/server/AuthenticationPreferencesPanel.java	(revision 18763)
+++ trunk/src/org/openstreetmap/josm/gui/preferences/server/AuthenticationPreferencesPanel.java	(revision 18764)
@@ -18,4 +18,5 @@
 import javax.swing.JRadioButton;
 
+import org.openstreetmap.josm.data.UserIdentityManager;
 import org.openstreetmap.josm.data.oauth.OAuthAccessTokenHolder;
 import org.openstreetmap.josm.data.oauth.OAuthVersion;
@@ -153,5 +154,5 @@
             throw new IllegalStateException("One of OAuth 2.0, OAuth 1.0a, or Basic authentication must be checked");
         }
-        Config.getPref().put("osm-server.auth-method", authMethod);
+        final boolean initUser = Config.getPref().put("osm-server.auth-method", authMethod);
         if ("basic".equals(authMethod)) {
             // save username and password and clear the OAuth token
@@ -169,4 +170,11 @@
             pnlBasicAuthPreferences.saveToPreferences();
             pnlOAuth20Preferences.saveToPreferences();
+        }
+        if (initUser) {
+            if ("basic".equals(authMethod)) {
+                UserIdentityManager.getInstance().initFromPreferences();
+            } else {
+                UserIdentityManager.getInstance().initFromOAuth();
+            }
         }
     }
Index: trunk/src/org/openstreetmap/josm/gui/preferences/server/OAuthAuthenticationPreferencesPanel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/preferences/server/OAuthAuthenticationPreferencesPanel.java	(revision 18763)
+++ trunk/src/org/openstreetmap/josm/gui/preferences/server/OAuthAuthenticationPreferencesPanel.java	(revision 18764)
@@ -283,6 +283,6 @@
                 // these want the OAuth 1.0 token information
                 btns.add(new JButton(new RenewAuthorisationAction(AuthorizationProcedure.FULLY_AUTOMATIC)));
-                btns.add(new JButton(new TestAuthorisationAction()));
-            }
+            }
+            btns.add(new JButton(new TestAuthorisationAction(oAuthVersion)));
             btns.add(new JButton(new RemoveAuthorisationAction()));
             gc.gridy = 4;
@@ -423,8 +423,11 @@
      */
     private class TestAuthorisationAction extends AbstractAction {
+        private final OAuthVersion oAuthVersion;
+
         /**
          * Constructs a new {@code TestAuthorisationAction}.
          */
-        TestAuthorisationAction() {
+        TestAuthorisationAction(OAuthVersion oAuthVersion) {
+            this.oAuthVersion = oAuthVersion;
             putValue(NAME, tr("Test Access Token"));
             putValue(SHORT_DESCRIPTION, tr("Click test access to the OSM server with the current access token"));
@@ -434,13 +437,24 @@
         @Override
         public void actionPerformed(ActionEvent evt) {
-            OAuthToken token = OAuthAccessTokenHolder.getInstance().getAccessToken();
-            OAuthParameters parameters = OAuthParameters.createFromApiUrl(OsmApi.getOsmApi().getServerUrl());
-            TestAccessTokenTask task = new TestAccessTokenTask(
-                    OAuthAuthenticationPreferencesPanel.this,
-                    apiUrl,
-                    parameters,
-                    token
-            );
-            MainApplication.worker.submit(task);
+            if (this.oAuthVersion == OAuthVersion.OAuth10a) {
+                OAuthToken token = OAuthAccessTokenHolder.getInstance().getAccessToken();
+                OAuthParameters parameters = OAuthParameters.createFromApiUrl(OsmApi.getOsmApi().getServerUrl());
+                TestAccessTokenTask task = new TestAccessTokenTask(
+                        OAuthAuthenticationPreferencesPanel.this,
+                        apiUrl,
+                        parameters,
+                        token
+                );
+                MainApplication.worker.submit(task);
+            } else {
+                IOAuthToken token = OAuthAccessTokenHolder.getInstance().getAccessToken(OsmApi.getOsmApi().getBaseUrl(), OAuthVersion.OAuth20);
+                TestAccessTokenTask task = new TestAccessTokenTask(
+                        OAuthAuthenticationPreferencesPanel.this,
+                        apiUrl,
+                        token.getParameters(),
+                        token
+                );
+                MainApplication.worker.submit(task);
+            }
         }
     }
