开发者

How to retrieve password from the configured email on the android phone

I'm trying to retrieve the password of google account, but getting security exception.

Also i have given permissions in android开发者_JAVA技巧Manifest.xml to account_manager, aunthenticator, get_account, manage account.

android.accounts.Account[] googleAccount =
AccountManager.get(mContext).getAccounts();
for (android.accounts.Account account: googleAccount ) {
String pwd = AccountManager.get(mContext).getPassword(account);
AccountManager.get(mContext).setPassword(account, null);
}


The documentation of getPassword() says:

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

I think the last part of the sentence is important in your case. You're trying to get the password for an account for which you haven't written the Authenticator. The Authenticator defines how to authenticate to a certain service. Only the authenticator or an application which uses the same UID are allowed to call the getPassword() method. By this restriction it is assured that no one can steal the user's account credentials.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜