Monday, January 10, 2011

Android AppEngine Login Error 500

Android caches authentication tokens. Therefore when getting a 500 error while authenticating against AppEngine the reason might be a timed out authentication token. In this case the token has to be invalidated and a new login request has to be send.

if (response.getStatusLine().getStatusCode() != 302) {
  Log.d(TAG, "Login failed. Trying again with new token.");
  AccountManager accountManager = AccountManager.get(context);
  accountManager.invalidateAuthToken("com.google",getAuthenticationToken(context));
}