OK, the URL was not right after all. The problem was that the token expired. I was able to solve this problem by canceling and reusing the token.
private class GetAuthTokenTask extends AsyncTask<Account, Object, String> { @Override protected String doInBackground(Account... accounts) { AccountManager manager = AccountManager.get(getApplicationContext()); Account account = accounts[0]; String token = this.buildToken(manager, account); manager.invalidateAuthToken(account.type, token); return this.buildToken(manager, account); } private String buildToken(AccountManager manager, Account account) { try { AccountManagerFuture<Bundle> future = manager.getAuthToken (account, "ah", false, null, null); Bundle bundle = future.getResult(); return bundle.getString(AccountManager.KEY_AUTHTOKEN); } catch (OperationCanceledException e) { Log.w(TAG, e.getMessage()); } catch (AuthenticatorException e) { Log.w(TAG, e.getMessage()); } catch (IOException e) { Log.w(TAG, e.getMessage()); } return null; } protected void onPostExecute(String authToken) { new GetCookieTask().execute(authToken); } }
Nick orton
source share