Search code examples
androidaccountmanagersecurityexception

Is it possible to add a google account to "Accounts & Sync" Without launching a login screen


I have tried many different approaches to solving this issue, that seems us solvable. I've implemented a C2DM messaging system with Apps engine (same as JumpNote example) and I want the Android Device to automatically create a specified google account without asking for credentials. I've used the following method:

    AccountManager accMgr = AccountManager.get(this);
    final Account account = new Account(this.getString(R.string.push_account), "com.google");
    accMgr.addAccountExplicitly(account, this.getString(R.string.push_account_pass), null);

This throws the following: java.lang.SecurityException: caller uid 10086 is different than the authenticator's uid

Does anyone ever succeded creating a google account without asking the user to manualy type credentials?

Thanks to anyone that shed some light on this.


Solution

  • This is almost certainly not what you want to do.

    Doing it the way that you are creates a massive security vulnerability, as anyone can unzip and decompile your APK and acquire the username and password you're using.

    Now they have access to any phone running your app - installing things from the web market seems like the most blatant risk.