What is the correct URL to get Auth Cookie from GAE based application

I have an android app. I want to connect to a server based on Google App Engine. I can get auth token from AccountManager. It seems the next thing I have to do is talk on the auth page to get a cookie. Following the awesome instructions here: http://blog.notdot.net/2010/05/Authenticating-against-App-Engine-from-an-Android-app I think my url should be:

https://MYAPP.appspot.com/_ah/login?continue=http://localhost/&auth=CrAZYl000ngToken 

but instead of redirecting I get a 500 server error:

 Error: Server Error The server encountered an error and could not complete your request. If the problem persists, please report your problem and mention this error message and the query that caused it. 

What's up with that? What will be the URL I'm going to? Or maybe I'm doing something else wrong?

+3
source share
1 answer

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); } } 
+9
source

All Articles