Added in [API level 5](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Constants](https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#constants) \| [Ctors](https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#pubctors) \| [Methods](https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#inhmethods)

# AbstractAccountAuthenticator

*** ** * ** ***

` public abstract class AbstractAccountAuthenticator `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.accounts.AbstractAccountAuthenticator |

<br />

*** ** * ** ***

Abstract base class for creating AccountAuthenticators. In order to be an authenticator one must extend this class, provide implementations for the abstract methods, and write a service that returns the result of `https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#getIBinder()` in the service's `https://developer.android.com/reference/android/app/Service#onBind(android.content.Intent)` when invoked with an intent with action `https://developer.android.com/reference/android/accounts/AccountManager#ACTION_AUTHENTICATOR_INTENT`. This service must specify the following intent filter and metadata tags in its AndroidManifest.xml file

```
  <intent-filter>
    <action android:name="android.accounts.AccountAuthenticator" />
  </intent-filter>
  <meta-data android:name="android.accounts.AccountAuthenticator"
            android:resource="@xml/authenticator" />
```
The `android:resource` attribute must point to a resource that looks like:

```
<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
   android:accountType="typeOfAuthenticator"
   android:icon="@drawable/icon"
   android:smallIcon="@drawable/miniIcon"
   android:label="@string/label"
   android:accountPreferences="@xml/account_preferences"
/>
```
Replace the icons and labels with your own resources. The `android:accountType` attribute must be a string that uniquely identifies your authenticator and will be the same string that user will use when making calls on the `https://developer.android.com/reference/android/accounts/AccountManager` and it also corresponds to `https://developer.android.com/reference/android/accounts/Account#type` for your accounts. One user of the android:icon is the "Account \& Sync" settings page and one user of the android:smallIcon is the Contact Application's tab panels.

The preferences attribute points to a PreferenceScreen xml hierarchy that contains a list of PreferenceScreens that can be invoked to manage the authenticator. An example is:

```
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
   <PreferenceCategory android:title="@string/title_fmt" />
   <PreferenceScreen
        android:key="key1"
        android:title="@string/key1_action"
        android:summary="@string/key1_summary">
        <intent
            android:action="key1.ACTION"
            android:targetPackage="key1.package"
            android:targetClass="key1.class" />
    </PreferenceScreen>
</PreferenceScreen>
```

The standard pattern for implementing any of the abstract methods is the following:

- If the supplied arguments are enough for the authenticator to fully satisfy the request then it will do so and return a `https://developer.android.com/reference/android/os/Bundle` that contains the results.
- If the authenticator needs information from the user to satisfy the request then it will create an `https://developer.android.com/reference/android/content/Intent` to an activity that will prompt the user for the information and then carry out the request. This intent must be returned in a Bundle as key `https://developer.android.com/reference/android/accounts/AccountManager#KEY_INTENT`.

  The activity needs to return the final result when it is complete so the Intent should contain the `https://developer.android.com/reference/android/accounts/AccountAuthenticatorResponse` as `https://developer.android.com/reference/android/accounts/AccountManager#KEY_ACCOUNT_AUTHENTICATOR_RESPONSE`. The activity must then call `https://developer.android.com/reference/android/accounts/AccountAuthenticatorResponse#onResult(android.os.Bundle)` or `https://developer.android.com/reference/android/accounts/AccountAuthenticatorResponse#onError(int,%20java.lang.String)` when it is complete.
- If the authenticator cannot synchronously process the request and return a result then it may choose to return null and then use the AccountManagerResponse to send the result when it has completed the request. This asynchronous option is not available for the `https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#addAccount(android.accounts.AccountAuthenticatorResponse,%20java.lang.String,%20java.lang.String,%20java.lang.String[],%20android.os.Bundle)` method, which must complete synchronously.

The following descriptions of each of the abstract authenticator methods will not describe the possible asynchronous nature of the request handling and will instead just describe the input parameters and the expected result.

When writing an activity to satisfy these requests one must pass in the AccountManagerResponse and return the result via that response when the activity finishes (or whenever else the activity author deems it is the correct time to respond).

## Summary

| ### Constants ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#KEY_CUSTOM_TOKEN_EXPIRY` Bundle key used for the `long` expiration time (in millis from the unix epoch) of the associated auth token. |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#AbstractAccountAuthenticator(android.content.Context)(https://developer.android.com/reference/android/content/Context context) ` |

| ### Public methods ||
|---|---|
| ` abstract https://developer.android.com/reference/android/os/Bundle` | ` https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#addAccount(android.accounts.AccountAuthenticatorResponse,%20java.lang.String,%20java.lang.String,%20java.lang.String[],%20android.os.Bundle)(https://developer.android.com/reference/android/accounts/AccountAuthenticatorResponse response, https://developer.android.com/reference/java/lang/String accountType, https://developer.android.com/reference/java/lang/String authTokenType, https://developer.android.com/reference/java/lang/String requiredFeatures, https://developer.android.com/reference/android/os/Bundle options) ` Adds an account of the specified accountType. |
| ` https://developer.android.com/reference/android/os/Bundle` | ` https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#addAccountFromCredentials(android.accounts.AccountAuthenticatorResponse,%20android.accounts.Account,%20android.os.Bundle)(https://developer.android.com/reference/android/accounts/AccountAuthenticatorResponse response, https://developer.android.com/reference/android/accounts/Account account, https://developer.android.com/reference/android/os/Bundle accountCredentials) ` Creates an account based on credentials provided by the authenticator instance of another user on the device, who has chosen to share the account with this user. |
| ` abstract https://developer.android.com/reference/android/os/Bundle` | ` https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#confirmCredentials(android.accounts.AccountAuthenticatorResponse,%20android.accounts.Account,%20android.os.Bundle)(https://developer.android.com/reference/android/accounts/AccountAuthenticatorResponse response, https://developer.android.com/reference/android/accounts/Account account, https://developer.android.com/reference/android/os/Bundle options) ` Checks that the user knows the credentials of an account. |
| ` abstract https://developer.android.com/reference/android/os/Bundle` | ` https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#editProperties(android.accounts.AccountAuthenticatorResponse,%20java.lang.String)(https://developer.android.com/reference/android/accounts/AccountAuthenticatorResponse response, https://developer.android.com/reference/java/lang/String accountType) ` Returns a Bundle that contains the Intent of the activity that can be used to edit the properties. |
| ` https://developer.android.com/reference/android/os/Bundle` | ` https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#finishSession(android.accounts.AccountAuthenticatorResponse,%20java.lang.String,%20android.os.Bundle)(https://developer.android.com/reference/android/accounts/AccountAuthenticatorResponse response, https://developer.android.com/reference/java/lang/String accountType, https://developer.android.com/reference/android/os/Bundle sessionBundle) ` Finishes the session started by #startAddAccountSession or #startUpdateCredentials by installing the account to device with AccountManager, or updating the local credentials. |
| ` https://developer.android.com/reference/android/os/Bundle` | ` https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#getAccountCredentialsForCloning(android.accounts.AccountAuthenticatorResponse,%20android.accounts.Account)(https://developer.android.com/reference/android/accounts/AccountAuthenticatorResponse response, https://developer.android.com/reference/android/accounts/Account account) ` Returns a Bundle that contains whatever is required to clone the account on a different user. |
| ` https://developer.android.com/reference/android/os/Bundle` | ` https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#getAccountRemovalAllowed(android.accounts.AccountAuthenticatorResponse,%20android.accounts.Account)(https://developer.android.com/reference/android/accounts/AccountAuthenticatorResponse response, https://developer.android.com/reference/android/accounts/Account account) ` Checks if the removal of this account is allowed. |
| ` abstract https://developer.android.com/reference/android/os/Bundle` | ` https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#getAuthToken(android.accounts.AccountAuthenticatorResponse,%20android.accounts.Account,%20java.lang.String,%20android.os.Bundle)(https://developer.android.com/reference/android/accounts/AccountAuthenticatorResponse response, https://developer.android.com/reference/android/accounts/Account account, https://developer.android.com/reference/java/lang/String authTokenType, https://developer.android.com/reference/android/os/Bundle options) ` Gets an authtoken for an account. |
| ` abstract https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#getAuthTokenLabel(java.lang.String)(https://developer.android.com/reference/java/lang/String authTokenType) ` Ask the authenticator for a localized label for the given authTokenType. |
| ` final https://developer.android.com/reference/android/os/IBinder` | ` https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#getIBinder()() ` |
| ` abstract https://developer.android.com/reference/android/os/Bundle` | ` https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#hasFeatures(android.accounts.AccountAuthenticatorResponse,%20android.accounts.Account,%20java.lang.String[])(https://developer.android.com/reference/android/accounts/AccountAuthenticatorResponse response, https://developer.android.com/reference/android/accounts/Account account, https://developer.android.com/reference/java/lang/String features) ` Checks if the account supports all the specified authenticator specific features. |
| ` https://developer.android.com/reference/android/os/Bundle` | ` https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#isCredentialsUpdateSuggested(android.accounts.AccountAuthenticatorResponse,%20android.accounts.Account,%20java.lang.String)(https://developer.android.com/reference/android/accounts/AccountAuthenticatorResponse response, https://developer.android.com/reference/android/accounts/Account account, https://developer.android.com/reference/java/lang/String statusToken) ` Checks if update of the account credentials is suggested. |
| ` https://developer.android.com/reference/android/os/Bundle` | ` https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#startAddAccountSession(android.accounts.AccountAuthenticatorResponse,%20java.lang.String,%20java.lang.String,%20java.lang.String[],%20android.os.Bundle)(https://developer.android.com/reference/android/accounts/AccountAuthenticatorResponse response, https://developer.android.com/reference/java/lang/String accountType, https://developer.android.com/reference/java/lang/String authTokenType, https://developer.android.com/reference/java/lang/String requiredFeatures, https://developer.android.com/reference/android/os/Bundle options) ` Starts the add account session to authenticate user to an account of the specified accountType. |
| ` https://developer.android.com/reference/android/os/Bundle` | ` https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#startUpdateCredentialsSession(android.accounts.AccountAuthenticatorResponse,%20android.accounts.Account,%20java.lang.String,%20android.os.Bundle)(https://developer.android.com/reference/android/accounts/AccountAuthenticatorResponse response, https://developer.android.com/reference/android/accounts/Account account, https://developer.android.com/reference/java/lang/String authTokenType, https://developer.android.com/reference/android/os/Bundle options) ` Asks user to re-authenticate for an account but defers updating the locally stored credentials. |
| ` abstract https://developer.android.com/reference/android/os/Bundle` | ` https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#updateCredentials(android.accounts.AccountAuthenticatorResponse,%20android.accounts.Account,%20java.lang.String,%20android.os.Bundle)(https://developer.android.com/reference/android/accounts/AccountAuthenticatorResponse response, https://developer.android.com/reference/android/accounts/Account account, https://developer.android.com/reference/java/lang/String authTokenType, https://developer.android.com/reference/android/os/Bundle options) ` Update the locally stored credentials for an account. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Constants

### KEY_CUSTOM_TOKEN_EXPIRY

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String KEY_CUSTOM_TOKEN_EXPIRY
```

Bundle key used for the `long` expiration time (in millis from the unix epoch) of the associated auth token.

<br />

**See also:**

- `https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#getAuthToken(android.accounts.AccountAuthenticatorResponse,%20android.accounts.Account,%20java.lang.String,%20android.os.Bundle)`

Constant Value: "android.accounts.expiry"

## Public constructors

### AbstractAccountAuthenticator

Added in [API level 5](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public AbstractAccountAuthenticator (Context context)
```

<br />

<br />

| Parameters ||
|---|---|
| `context` | `Context` <br /> |

## Public methods

### addAccount

Added in [API level 5](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract Bundle addAccount (AccountAuthenticatorResponse response, 
                String accountType, 
                String authTokenType, 
                String[] requiredFeatures, 
                Bundle options)
```

Adds an account of the specified accountType.

<br />

| Parameters ||
|---|---|
| `response` | `AccountAuthenticatorResponse`: to send the result back to the AccountManager, will never be null <br /> |
| `accountType` | `String`: the type of account to add, will never be null <br /> |
| `authTokenType` | `String`: the type of auth token to retrieve after adding the account, may be null <br /> |
| `requiredFeatures` | `String`: a String array of authenticator-specific features that the added account must support, may be null <br /> |
| `options` | `Bundle`: a Bundle of authenticator-specific options. It always contains `https://developer.android.com/reference/android/accounts/AccountManager#KEY_CALLER_PID` and `https://developer.android.com/reference/android/accounts/AccountManager#KEY_CALLER_UID` fields which will let authenticator know the identity of the caller. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/os/Bundle` | a Bundle result or null if the result is to be returned via the response. The result will contain either: - `https://developer.android.com/reference/android/accounts/AccountManager#KEY_INTENT`, or - `https://developer.android.com/reference/android/accounts/AccountManager#KEY_ACCOUNT_NAME` and `https://developer.android.com/reference/android/accounts/AccountManager#KEY_ACCOUNT_TYPE` of the account that was added, or - `https://developer.android.com/reference/android/accounts/AccountManager#KEY_ERROR_CODE` and `https://developer.android.com/reference/android/accounts/AccountManager#KEY_ERROR_MESSAGE` to indicate an error <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/accounts/NetworkErrorException` | if the authenticator could not honor the request due to a network error |

### addAccountFromCredentials

Added in [API level 18](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Bundle addAccountFromCredentials (AccountAuthenticatorResponse response, 
                Account account, 
                Bundle accountCredentials)
```

Creates an account based on credentials provided by the authenticator instance of another user on the device, who has chosen to share the account with this user.

<br />

| Parameters ||
|---|---|
| `response` | `AccountAuthenticatorResponse`: to send the result back to the AccountManager, will never be null <br /> |
| `account` | `Account`: the account to clone, will never be null <br /> |
| `accountCredentials` | `Bundle`: the Bundle containing the required credentials to create the account. Contents of the Bundle are only meaningful to the authenticator. This Bundle is provided by `https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#getAccountCredentialsForCloning(android.accounts.AccountAuthenticatorResponse,%20android.accounts.Account)`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/os/Bundle` | a Bundle result or null if the result is to be returned via the response. <br /> |

| Throws ||
|---|---|
|   | android.accounts.NetworkErrorException |
| `https://developer.android.com/reference/android/accounts/NetworkErrorException` |   |

**See also:**

- `https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#getAccountCredentialsForCloning(android.accounts.AccountAuthenticatorResponse,%20android.accounts.Account)`

### confirmCredentials

Added in [API level 5](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract Bundle confirmCredentials (AccountAuthenticatorResponse response, 
                Account account, 
                Bundle options)
```

Checks that the user knows the credentials of an account.

<br />

| Parameters ||
|---|---|
| `response` | `AccountAuthenticatorResponse`: to send the result back to the AccountManager, will never be null <br /> |
| `account` | `Account`: the account whose credentials are to be checked, will never be null <br /> |
| `options` | `Bundle`: a Bundle of authenticator-specific options, may be null <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/os/Bundle` | a Bundle result or null if the result is to be returned via the response. The result will contain either: - `https://developer.android.com/reference/android/accounts/AccountManager#KEY_INTENT`, or - `https://developer.android.com/reference/android/accounts/AccountManager#KEY_BOOLEAN_RESULT`, true if the check succeeded, false otherwise - `https://developer.android.com/reference/android/accounts/AccountManager#KEY_ERROR_CODE` and `https://developer.android.com/reference/android/accounts/AccountManager#KEY_ERROR_MESSAGE` to indicate an error <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/accounts/NetworkErrorException` | if the authenticator could not honor the request due to a network error |

### editProperties

Added in [API level 5](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract Bundle editProperties (AccountAuthenticatorResponse response, 
                String accountType)
```

Returns a Bundle that contains the Intent of the activity that can be used to edit the properties. In order to indicate success the activity should call response.setResult() with a non-null Bundle.

<br />

| Parameters ||
|---|---|
| `response` | `AccountAuthenticatorResponse`: used to set the result for the request. If the Constants.INTENT_KEY is set in the bundle then this response field is to be used for sending future results if and when the Intent is started. <br /> |
| `accountType` | `String`: the AccountType whose properties are to be edited. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/os/Bundle` | a Bundle containing the result or the Intent to start to continue the request. If this is null then the request is considered to still be active and the result should sent later using response. <br /> |

### finishSession

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Bundle finishSession (AccountAuthenticatorResponse response, 
                String accountType, 
                Bundle sessionBundle)
```

Finishes the session started by #startAddAccountSession or #startUpdateCredentials by installing the account to device with AccountManager, or updating the local credentials. File I/O may be performed in this call.

Note: when overriding this method, `https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#startAddAccountSession(android.accounts.AccountAuthenticatorResponse,%20java.lang.String,%20java.lang.String,%20java.lang.String[],%20android.os.Bundle)` and `https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#startUpdateCredentialsSession(android.accounts.AccountAuthenticatorResponse,%20android.accounts.Account,%20java.lang.String,%20android.os.Bundle)` should be overridden too.

<br />

<br />

| Parameters ||
|---|---|
| `response` | `AccountAuthenticatorResponse`: to send the result back to the AccountManager, will never be null <br /> |
| `accountType` | `String`: the type of account to authenticate with, will never be null <br /> |
| `sessionBundle` | `Bundle`: a bundle of session data created by `https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#startAddAccountSession(android.accounts.AccountAuthenticatorResponse,%20java.lang.String,%20java.lang.String,%20java.lang.String[],%20android.os.Bundle)` used for adding account to device, or by `https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#startUpdateCredentialsSession(android.accounts.AccountAuthenticatorResponse,%20android.accounts.Account,%20java.lang.String,%20android.os.Bundle)` used for updating local credentials. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/os/Bundle` | a Bundle result or null if the result is to be returned via the response. The result will contain either: - `https://developer.android.com/reference/android/accounts/AccountManager#KEY_INTENT`, or - `https://developer.android.com/reference/android/accounts/AccountManager#KEY_ACCOUNT_NAME` and `https://developer.android.com/reference/android/accounts/AccountManager#KEY_ACCOUNT_TYPE` of the account that was added or local credentials were updated, and optional `https://developer.android.com/reference/android/accounts/AccountManager#KEY_ACCOUNT_STATUS_TOKEN` for checking the status of the account later, or - `https://developer.android.com/reference/android/accounts/AccountManager#KEY_ERROR_CODE` and `https://developer.android.com/reference/android/accounts/AccountManager#KEY_ERROR_MESSAGE` to indicate an error <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/accounts/NetworkErrorException` | if the authenticator could not honor the request due to a network error |

**See also:**

- `https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#startAddAccountSession(android.accounts.AccountAuthenticatorResponse,%20java.lang.String,%20java.lang.String,%20java.lang.String[],%20android.os.Bundle)`

### getAccountCredentialsForCloning

Added in [API level 18](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Bundle getAccountCredentialsForCloning (AccountAuthenticatorResponse response, 
                Account account)
```

Returns a Bundle that contains whatever is required to clone the account on a different user. The Bundle is passed to the authenticator instance in the target user via `https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#addAccountFromCredentials(android.accounts.AccountAuthenticatorResponse,%20android.accounts.Account,%20android.os.Bundle)`. The default implementation returns null, indicating that cloning is not supported.

<br />

| Parameters ||
|---|---|
| `response` | `AccountAuthenticatorResponse`: to send the result back to the AccountManager, will never be null <br /> |
| `account` | `Account`: the account to clone, will never be null <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/os/Bundle` | a Bundle result or null if the result is to be returned via the response. <br /> |

| Throws ||
|---|---|
|   | android.accounts.NetworkErrorException |
| `https://developer.android.com/reference/android/accounts/NetworkErrorException` |   |

**See also:**

- `https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#addAccountFromCredentials(android.accounts.AccountAuthenticatorResponse,%20android.accounts.Account,%20android.os.Bundle)`

### getAccountRemovalAllowed

Added in [API level 5](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Bundle getAccountRemovalAllowed (AccountAuthenticatorResponse response, 
                Account account)
```

Checks if the removal of this account is allowed.

<br />

| Parameters ||
|---|---|
| `response` | `AccountAuthenticatorResponse`: to send the result back to the AccountManager, will never be null <br /> |
| `account` | `Account`: the account to check, will never be null <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/os/Bundle` | a Bundle result or null if the result is to be returned via the response. The result will contain either: - `https://developer.android.com/reference/android/accounts/AccountManager#KEY_INTENT`, or - `https://developer.android.com/reference/android/accounts/AccountManager#KEY_BOOLEAN_RESULT`, true if the removal of the account is allowed, false otherwise - `https://developer.android.com/reference/android/accounts/AccountManager#KEY_ERROR_CODE` and `https://developer.android.com/reference/android/accounts/AccountManager#KEY_ERROR_MESSAGE` to indicate an error <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/accounts/NetworkErrorException` | if the authenticator could not honor the request due to a network error |

### getAuthToken

Added in [API level 5](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract Bundle getAuthToken (AccountAuthenticatorResponse response, 
                Account account, 
                String authTokenType, 
                Bundle options)
```

Gets an authtoken for an account. If not `null`, the resultant `https://developer.android.com/reference/android/os/Bundle` will contain different sets of keys depending on whether a token was successfully issued and, if not, whether one could be issued via some `https://developer.android.com/reference/android/app/Activity`.

If a token cannot be provided without some additional activity, the Bundle should contain `https://developer.android.com/reference/android/accounts/AccountManager#KEY_INTENT` with an associated `https://developer.android.com/reference/android/content/Intent`. On the other hand, if there is no such activity, then a Bundle containing `https://developer.android.com/reference/android/accounts/AccountManager#KEY_ERROR_CODE` and `https://developer.android.com/reference/android/accounts/AccountManager#KEY_ERROR_MESSAGE` should be returned.

If a token can be successfully issued, the implementation should return the `https://developer.android.com/reference/android/accounts/AccountManager#KEY_ACCOUNT_NAME` and `https://developer.android.com/reference/android/accounts/AccountManager#KEY_ACCOUNT_TYPE` of the account associated with the token as well as the `https://developer.android.com/reference/android/accounts/AccountManager#KEY_AUTHTOKEN`. In addition `https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator` implementations that declare themselves `android:customTokens=true` may also provide a non-negative `https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#KEY_CUSTOM_TOKEN_EXPIRY` long value containing the expiration timestamp of the expiration time (in millis since the unix epoch), tokens will be cached in memory based on application's packageName/signature for however long that was specified.

Implementers should assume that tokens will be cached on the basis of account and authTokenType. The system may ignore the contents of the supplied options Bundle when determining to re-use a cached token. Furthermore, implementers should assume a supplied expiration time will be treated as non-binding advice.

Finally, note that for `android:customTokens=false` authenticators, tokens are cached indefinitely until some client calls `https://developer.android.com/reference/android/accounts/AccountManager#invalidateAuthToken(java.lang.String,%20java.lang.String)`.

<br />

| Parameters ||
|---|---|
| `response` | `AccountAuthenticatorResponse`: to send the result back to the AccountManager, will never be null <br /> |
| `account` | `Account`: the account whose credentials are to be retrieved, will never be null <br /> |
| `authTokenType` | `String`: the type of auth token to retrieve, will never be null <br /> |
| `options` | `Bundle`: a Bundle of authenticator-specific options. It always contains `https://developer.android.com/reference/android/accounts/AccountManager#KEY_CALLER_PID` and `https://developer.android.com/reference/android/accounts/AccountManager#KEY_CALLER_UID` fields which will let authenticator know the identity of the caller. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/os/Bundle` | a Bundle result or null if the result is to be returned via the response. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/accounts/NetworkErrorException` | if the authenticator could not honor the request due to a network error |

### getAuthTokenLabel

Added in [API level 5](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract String getAuthTokenLabel (String authTokenType)
```

Ask the authenticator for a localized label for the given authTokenType.

<br />

| Parameters ||
|---|---|
| `authTokenType` | `String`: the authTokenType whose label is to be returned, will never be null <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the localized label of the auth token type, may be null if the type isn't known <br /> |

### getIBinder

Added in [API level 5](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final IBinder getIBinder ()
```

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/os/IBinder` | the IBinder for the AccountAuthenticator <br /> |

### hasFeatures

Added in [API level 5](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract Bundle hasFeatures (AccountAuthenticatorResponse response, 
                Account account, 
                String[] features)
```

Checks if the account supports all the specified authenticator specific features.

<br />

| Parameters ||
|---|---|
| `response` | `AccountAuthenticatorResponse`: to send the result back to the AccountManager, will never be null <br /> |
| `account` | `Account`: the account to check, will never be null <br /> |
| `features` | `String`: an array of features to check, will never be null <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/os/Bundle` | a Bundle result or null if the result is to be returned via the response. The result will contain either: - `https://developer.android.com/reference/android/accounts/AccountManager#KEY_INTENT`, or - `https://developer.android.com/reference/android/accounts/AccountManager#KEY_BOOLEAN_RESULT`, true if the account has all the features, false otherwise - `https://developer.android.com/reference/android/accounts/AccountManager#KEY_ERROR_CODE` and `https://developer.android.com/reference/android/accounts/AccountManager#KEY_ERROR_MESSAGE` to indicate an error <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/accounts/NetworkErrorException` | if the authenticator could not honor the request due to a network error |

### isCredentialsUpdateSuggested

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Bundle isCredentialsUpdateSuggested (AccountAuthenticatorResponse response, 
                Account account, 
                String statusToken)
```

Checks if update of the account credentials is suggested.

<br />

| Parameters ||
|---|---|
| `response` | `AccountAuthenticatorResponse`: to send the result back to the AccountManager, will never be null. <br /> |
| `account` | `Account`: the account to check, will never be null <br /> |
| `statusToken` | `String`: a String of token which can be used to check the status of locally stored credentials and if update of credentials is suggested <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/os/Bundle` | a Bundle result or null if the result is to be returned via the response. The result will contain either: - `https://developer.android.com/reference/android/accounts/AccountManager#KEY_BOOLEAN_RESULT`, true if update of account's credentials is suggested, false otherwise - `https://developer.android.com/reference/android/accounts/AccountManager#KEY_ERROR_CODE` and `https://developer.android.com/reference/android/accounts/AccountManager#KEY_ERROR_MESSAGE` to indicate an error <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/accounts/NetworkErrorException` | if the authenticator could not honor the request due to a network error |

### startAddAccountSession

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Bundle startAddAccountSession (AccountAuthenticatorResponse response, 
                String accountType, 
                String authTokenType, 
                String[] requiredFeatures, 
                Bundle options)
```

Starts the add account session to authenticate user to an account of the specified accountType. No file I/O should be performed in this call. Account should be added to device only when `https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#finishSession(android.accounts.AccountAuthenticatorResponse,%20java.lang.String,%20android.os.Bundle)` is called after this.

Note: when overriding this method, `https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#finishSession(android.accounts.AccountAuthenticatorResponse,%20java.lang.String,%20android.os.Bundle)` should be overridden too.

<br />

<br />

| Parameters ||
|---|---|
| `response` | `AccountAuthenticatorResponse`: to send the result back to the AccountManager, will never be null <br /> |
| `accountType` | `String`: the type of account to authenticate with, will never be null <br /> |
| `authTokenType` | `String`: the type of auth token to retrieve after authenticating with the account, may be null <br /> |
| `requiredFeatures` | `String`: a String array of authenticator-specific features that the account authenticated with must support, may be null <br /> |
| `options` | `Bundle`: a Bundle of authenticator-specific options, may be null <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/os/Bundle` | a Bundle result or null if the result is to be returned via the response. The result will contain either: - `https://developer.android.com/reference/android/accounts/AccountManager#KEY_INTENT`, or - `https://developer.android.com/reference/android/accounts/AccountManager#KEY_ACCOUNT_SESSION_BUNDLE` for adding the account to device later, and if account is authenticated, optional `https://developer.android.com/reference/android/accounts/AccountManager#KEY_PASSWORD` and `https://developer.android.com/reference/android/accounts/AccountManager#KEY_ACCOUNT_STATUS_TOKEN` for checking the status of the account, or - `https://developer.android.com/reference/android/accounts/AccountManager#KEY_ERROR_CODE` and `https://developer.android.com/reference/android/accounts/AccountManager#KEY_ERROR_MESSAGE` to indicate an error <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/accounts/NetworkErrorException` | if the authenticator could not honor the request due to a network error |

**See also:**

- `https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#finishSession(android.accounts.AccountAuthenticatorResponse,%20java.lang.String,%20android.os.Bundle)`

### startUpdateCredentialsSession

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Bundle startUpdateCredentialsSession (AccountAuthenticatorResponse response, 
                Account account, 
                String authTokenType, 
                Bundle options)
```

Asks user to re-authenticate for an account but defers updating the locally stored credentials. No file I/O should be performed in this call. Local credentials should be updated only when `https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#finishSession(android.accounts.AccountAuthenticatorResponse,%20java.lang.String,%20android.os.Bundle)` is called after this.

Note: when overriding this method, `https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#finishSession(android.accounts.AccountAuthenticatorResponse,%20java.lang.String,%20android.os.Bundle)` should be overridden too.

<br />

<br />

| Parameters ||
|---|---|
| `response` | `AccountAuthenticatorResponse`: to send the result back to the AccountManager, will never be null <br /> |
| `account` | `Account`: the account whose credentials are to be updated, will never be null <br /> |
| `authTokenType` | `String`: the type of auth token to retrieve after updating the credentials, may be null <br /> |
| `options` | `Bundle`: a Bundle of authenticator-specific options, may be null <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/os/Bundle` | a Bundle result or null if the result is to be returned via the response. The result will contain either: - `https://developer.android.com/reference/android/accounts/AccountManager#KEY_INTENT`, or - `https://developer.android.com/reference/android/accounts/AccountManager#KEY_ACCOUNT_SESSION_BUNDLE` for updating the locally stored credentials later, and if account is re-authenticated, optional `https://developer.android.com/reference/android/accounts/AccountManager#KEY_PASSWORD` and `https://developer.android.com/reference/android/accounts/AccountManager#KEY_ACCOUNT_STATUS_TOKEN` for checking the status of the account later, or - `https://developer.android.com/reference/android/accounts/AccountManager#KEY_ERROR_CODE` and `https://developer.android.com/reference/android/accounts/AccountManager#KEY_ERROR_MESSAGE` to indicate an error <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/accounts/NetworkErrorException` | if the authenticator could not honor the request due to a network error |

**See also:**

- `https://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator#finishSession(android.accounts.AccountAuthenticatorResponse,%20java.lang.String,%20android.os.Bundle)`

### updateCredentials

Added in [API level 5](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract Bundle updateCredentials (AccountAuthenticatorResponse response, 
                Account account, 
                String authTokenType, 
                Bundle options)
```

Update the locally stored credentials for an account.

<br />

| Parameters ||
|---|---|
| `response` | `AccountAuthenticatorResponse`: to send the result back to the AccountManager, will never be null <br /> |
| `account` | `Account`: the account whose credentials are to be updated, will never be null <br /> |
| `authTokenType` | `String`: the type of auth token to retrieve after updating the credentials, may be null <br /> |
| `options` | `Bundle`: a Bundle of authenticator-specific options, may be null <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/os/Bundle` | a Bundle result or null if the result is to be returned via the response. The result will contain either: - `https://developer.android.com/reference/android/accounts/AccountManager#KEY_INTENT`, or - `https://developer.android.com/reference/android/accounts/AccountManager#KEY_ACCOUNT_NAME` and `https://developer.android.com/reference/android/accounts/AccountManager#KEY_ACCOUNT_TYPE` of the account whose credentials were updated, or - `https://developer.android.com/reference/android/accounts/AccountManager#KEY_ERROR_CODE` and `https://developer.android.com/reference/android/accounts/AccountManager#KEY_ERROR_MESSAGE` to indicate an error <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/accounts/NetworkErrorException` | if the authenticator could not honor the request due to a network error |