微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android从客户经理获取gmail用户名和密码

我正在为Android编写GMail客户端.我想在ListView中列出所有GMail帐户.当用户单击一个项目时,我希望程序检索相应帐户的密码.

但是,我得到一个SecurityException:

java.lang.SecurityException: caller uid 10107 is different than the authenticator's uid

这是我的代码

AccountManager accountManager = AccountManager.get(context);

this.username = account.name;
this.password = accountManager.getpassword(account); //this is where I get the exception

我在AndroidManifest.xml中拥有所有这些权限:

根据Android reference,唯一需要的权限应该是MANAGE_ACCOUNTS.

我的代码有什么问题?

最佳答案
您可以获得authtoken,但无法获得用户的实际凭据.实际的信用只能由创建它们的应用程序访问.从getpassword方法的文档(强调我的):

This method requires the caller to hold the permission AUTHENTICATE_ACCOUNTS and to have the same UID as the account’s authenticator.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐