Search code examples
androidgoogle-app-engineaccountmanager

Getting an auth token for appengine in ICS


I am having a problem retrieving an authentication token for an appengine application in Android.

I am following the docs, in that I get the users google account, and attempt to get the auth token from the account manager which works fine. However I get an intent back from the account manager, which is also fine, as this means user input is required.

The problem begins when I try to start the activity (GrantCredentialsPermissionActivity) that prompts the user to grant access. It simply throws a null pointer exception on creation. There is a bug logged here.

This has only been happening since I upgraded to ICS 4.0.3, and I have found others online that are having trouble with this, but I am struggling to find a solution. Has anyone else had this problem and found a solution? I know there are other questions in this area on stack overflow, but the 'solutions' are unsatisfactory (usually talking about invalidating tokens, which I have done).

Cheers,


Solution

  • Ok so I figured this out! I had been doing this to get the accounts from the account manager:

    accountManager.getAccounts();
    

    Which returned all accounts. I had two accounts that had the same email address associated with them, and when I looped over the accounts I matched a samsung account by email instead of the gmail one. I changed the call to get accounts to this:

    accountManager.getAccountsByType("com.google");
    

    So my fault, but an annoying one to find, hopefully this helps someone else.