Share via


AccountManager.SetAuthToken(Account, String, String) Method

Definition

Adds an auth token to the AccountManager cache for an account.

[Android.Runtime.Register("setAuthToken", "(Landroid/accounts/Account;Ljava/lang/String;Ljava/lang/String;)V", "GetSetAuthToken_Landroid_accounts_Account_Ljava_lang_String_Ljava_lang_String_Handler")]
[Android.Runtime.RequiresPermission("android.permission.AUTHENTICATE_ACCOUNTS")]
public virtual void SetAuthToken (Android.Accounts.Account? account, string? authTokenType, string? authToken);
[<Android.Runtime.Register("setAuthToken", "(Landroid/accounts/Account;Ljava/lang/String;Ljava/lang/String;)V", "GetSetAuthToken_Landroid_accounts_Account_Ljava_lang_String_Ljava_lang_String_Handler")>]
[<Android.Runtime.RequiresPermission("android.permission.AUTHENTICATE_ACCOUNTS")>]
abstract member SetAuthToken : Android.Accounts.Account * string * string -> unit
override this.SetAuthToken : Android.Accounts.Account * string * string -> unit

Parameters

account
Account

The account to set an auth token for

authTokenType
String

The type of the auth token, see {#getAuthToken}

authToken
String

The auth token to add to the cache

Attributes

Remarks

Adds an auth token to the AccountManager cache for an account. If the account does not exist then this call has no effect. Replaces any previous auth token for this account and auth token type. Intended for use by the authenticator, not directly by applications.

It is safe to call this method from the main thread.

This method requires the caller to have a signature match with the authenticator that manages the specified account.

<b>NOTE:</b> If targeting your app to work on API level 22 and before, AUTHENTICATE_ACCOUNTS permission and same UID as account's authenticator is needed for those platforms. See docs for this function in API level 22.

Java documentation for android.accounts.AccountManager.setAuthToken(android.accounts.Account, java.lang.String, java.lang.String).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to