Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9031787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:49:04+00:00 2026-06-16T07:49:04+00:00

I’m doing authentication of android app against an app engine server, basically following this

  • 0

I’m doing authentication of android app against an app engine server, basically following this post: http://blog.notdot.net/2010/05/Authenticating-against-App-Engine-from-an-Android-app.

It appears that the cookie that I get at the end of the process is no good – I’m getting 401, so I tried copying the cookie and testing it in the browser, and still getting 401. When copying the browser cookie to the android app, the request works.

How could I be getting an invalid cookie? I’ve even tried invalidating the tokens, but still getting the same result…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T07:49:06+00:00Added an answer on June 16, 2026 at 7:49 am

    For some reason this worked: I changed the URL for the initial cookie request from https to http, then changed it back.

    But in the end I decided to change my implementation and go with loopj as alistair suggested. The result is far more elegant. This is my login activity (note that I’m connecting the client to a persistent cookie storage given by loopj api):

    public class AccountList extends ListActivity {
        protected AccountManager accountManager;
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            accountManager = AccountManager.get(getApplicationContext());
            Account[] accounts = accountManager.getAccountsByType("com.google");
            this.setListAdapter(new ArrayAdapter<Account>(this, R.layout.list_item, accounts));   
        }
    
        @Override
        protected void onListItemClick(ListView l, View v, int position, long id) {
            Account account = (Account)getListView().getItemAtPosition(position);
            accountManager.invalidateAuthToken("com.google", null);
            accountManager.getAuthToken(account, "ah", null, this, new GetAuthTokenCallback(), null);
        }
    
        private class GetAuthTokenCallback implements AccountManagerCallback<Bundle> {
            public void run(AccountManagerFuture<Bundle> result) {
                AsyncHttpClient client = new AsyncHttpClient();
                PersistentCookieStore myCookieStore = new PersistentCookieStore(getBaseContext());
                client.setCookieStore(myCookieStore);
                try {
                    Bundle bundle;
                    bundle = result.getResult();
                    Intent intent = (Intent)bundle.get(AccountManager.KEY_INTENT);
                    if(intent != null) {
                        // User input required
                        startActivity(intent);
                    } else {
                        String token = bundle.getString(AccountManager.KEY_AUTHTOKEN);
                        String url = "http://myapp.appspot.com/_ah/login?continue=http://localhost/&auth=" + token;
                        client.post(url, new AsyncHttpResponseHandler());
                        Intent backToMainActivity = new Intent(getApplicationContext(), MainActivity.class);
                        startActivity(backToMainActivity);
                    }
                } catch (OperationCanceledException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (AuthenticatorException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
    }
    

    Because loopj gives persistent cookie storage, all I have to do in another activity is to initialize a client and connect it with the persistent cookie storage. This gives the new client all of the cookies I got from the login activity. Initialization looks something like this:

    AsyncHttpClient client = new AsyncHttpClient();
    client.setCookieStore(new PersistentCookieStore(this));
    

    BTW & FYI: The loopj library uses the SharedPreferences API in order to store the cookies, and wraps it nicely as PersistentCookieStore.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.