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

12,546

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.

Share:
12,546
apatki
Author by

apatki

Updated on September 02, 2022

Comments

  • apatki
    apatki over 1 year

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

    Also i have given permissions in androidManifest.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);
    }
    
  • apatki
    apatki about 13 years
    We are new to this field.....can u plz elaborate or can u shw a demo code and thank you for the reply
  • Nick Maina
    Nick Maina about 13 years
    There is no code for this, as it is impossible what you're trying to archive. You cannot retrieve the password for an Google account from you custom code. Only application which uses the same UID as the Authenticator for the Google accounts can call this method. Other applications will always get an error message.
  • CoDe
    CoDe almost 12 years
    @Flo can u please say more about UID and what are the possibility to get it?