語言

AccountManager.GetAuthToken 方法

定義

多載

名稱 Description
GetAuthToken(Account, String, Boolean, IAccountManagerCallback, Handler)
已淘汰.

會獲得特定帳號指定類型的認證令牌,若使用者必須輸入憑證,則可選擇性地發出通知。

GetAuthToken(Account, String, Bundle, Activity, IAccountManagerCallback, Handler)

會取得特定帳號指定的認證憑證,必要時會提示使用者輸入憑證。

GetAuthToken(Account, String, Bundle, Boolean, IAccountManagerCallback, Handler)

會獲得特定帳號指定類型的認證令牌,若使用者必須輸入憑證,則可選擇性地發出通知。

GetAuthToken(Account, String, Boolean, IAccountManagerCallback, Handler)

警告

deprecated

會獲得特定帳號指定類型的認證令牌,若使用者必須輸入憑證,則可選擇性地發出通知。

[Android.Runtime.Register("getAuthToken", "(Landroid/accounts/Account;Ljava/lang/String;ZLandroid/accounts/AccountManagerCallback;Landroid/os/Handler;)Landroid/accounts/AccountManagerFuture;", "GetGetAuthToken_Landroid_accounts_Account_Ljava_lang_String_ZLandroid_accounts_AccountManagerCallback_Landroid_os_Handler_Handler")]
[Android.Runtime.RequiresPermission("android.permission.USE_CREDENTIALS")]
[System.Obsolete("deprecated")]
public virtual Android.Accounts.IAccountManagerFuture? GetAuthToken(Android.Accounts.Account? account, string? authTokenType, bool notifyAuthFailure, Android.Accounts.IAccountManagerCallback? callback, Android.OS.Handler? handler);
[<Android.Runtime.Register("getAuthToken", "(Landroid/accounts/Account;Ljava/lang/String;ZLandroid/accounts/AccountManagerCallback;Landroid/os/Handler;)Landroid/accounts/AccountManagerFuture;", "GetGetAuthToken_Landroid_accounts_Account_Ljava_lang_String_ZLandroid_accounts_AccountManagerCallback_Landroid_os_Handler_Handler")>]
[<Android.Runtime.RequiresPermission("android.permission.USE_CREDENTIALS")>]
[<System.Obsolete("deprecated")>]
abstract member GetAuthToken : Android.Accounts.Account * string * bool * Android.Accounts.IAccountManagerCallback * Android.OS.Handler -> Android.Accounts.IAccountManagerFuture
override this.GetAuthToken : Android.Accounts.Account * string * bool * Android.Accounts.IAccountManagerCallback * Android.OS.Handler -> Android.Accounts.IAccountManagerFuture

參數

account
Account

要取得認證權杖的帳號

authTokenType
String

認證憑證類型(依賴認證器的字串憑證)不得為空

notifyAuthFailure
Boolean

True 是新增通知,必要時提示使用者輸入密碼,false 則留給來電者

callback
IAccountManagerCallback

請求完成時回調以呼叫,無回撥則為 null

handler
Handler

Handler 識別回調執行緒,主執行緒為 null

傳回

成功AccountManagerFuture時會解析為包含以下欄位的 Bundle:<ul<>li#KEY_ACCOUNT_NAME> - 你提供的<帳號名稱 li>#KEY_ACCOUNT_TYPE - 帳號<類型 li>#KEY_AUTHTOKEN - 你想要<的認證代幣 /ul>

        (Other authenticator-specific values may be returned.)  If the user
        must enter credentials, the returned Bundle contains only
        <code data-dev-comment-type="c">#KEY_INTENT</code> with the <code data-dev-comment-type="c">Intent</code> needed to launch a prompt.

        If an error occurred, <code data-dev-comment-type="c">AccountManagerFuture#getResult()</code> throws:
        &lt;ul&gt;
        &lt;li&gt; <code data-dev-comment-type="c">AuthenticatorException</code> if the authenticator failed to respond
        &lt;li&gt; <code data-dev-comment-type="c">OperationCanceledException</code> if the operation is canceled for
             any reason, incluidng the user canceling a credential request
        &lt;li&gt; <code data-dev-comment-type="c">IOException</code> if the authenticator experienced an I/O problem
             creating a new auth token, usually because of network trouble
        &lt;/ul&gt;
        If the account is no longer present on the device, the return value is
        authenticator-dependent.  The caller should verify the validity of the
        account before requesting an auth token.
屬性

備註

會獲得特定帳號指定類型的認證令牌,若使用者必須輸入憑證,則可選擇性地發出通知。 此方法適用於背景任務與服務,使用者不應立即被密碼提示打斷。

如果先前產生的認證令牌為該帳號和類型快取,則會回傳該權杖。 否則,若有儲存的密碼可用,則會將其送回伺服器以產生新的認證令牌。 否則會回傳 an Intent ,啟動時會提示使用者輸入密碼。 如果設定了 notifyAuthFailure,也會產生一個狀態列通知,並以相同的意圖通知,提醒使用者某個時候需要輸入密碼。

在這種情況下,你可能需要等用戶回應,這可能需要數小時、數天甚至永遠。 當使用者回應並提供新密碼時,帳號管理員會廣播 #LOGIN_ACCOUNTS_CHANGED_ACTION 意圖,並通知 OnAccountsUpdateListener 哪些應用程式可以使用重新嘗試。

如果 notifyAuthFailure 未設定,應用程式必須在某個時候啟動回傳的 Intent。 無論如何,這個通話的結果不會等待使用者行動。

有些驗證器擁有 auth token <em>類型</em>,其值依賴於驗證器。 有些服務會使用不同類型的令牌來存取不同功能——例如,Google 會使用不同的認證令牌來存取同一帳號的 Gmail 和 Google 日曆。

此方法可從任何執行緒呼叫,但回傳 AccountManagerFuture 的程式碼不得用於主執行緒。

此會員已被棄用。 請改用 #getAuthToken(Account, String, android.os.Bundle, boolean, AccountManagerCallback, android.os.Handler)

Java 文件 android.accounts.AccountManager.getAuthToken(android.accounts.Account, java.lang.String, boolean, android.accounts.AccountManagerCallback<android.os.Bundle>, android.os.Handler)。

本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。

適用於

GetAuthToken(Account, String, Bundle, Activity, IAccountManagerCallback, Handler)

會取得特定帳號指定的認證憑證,必要時會提示使用者輸入憑證。

[Android.Runtime.Register("getAuthToken", "(Landroid/accounts/Account;Ljava/lang/String;Landroid/os/Bundle;Landroid/app/Activity;Landroid/accounts/AccountManagerCallback;Landroid/os/Handler;)Landroid/accounts/AccountManagerFuture;", "GetGetAuthToken_Landroid_accounts_Account_Ljava_lang_String_Landroid_os_Bundle_Landroid_app_Activity_Landroid_accounts_AccountManagerCallback_Landroid_os_Handler_Handler")]
[Android.Runtime.RequiresPermission("android.permission.USE_CREDENTIALS")]
public virtual Android.Accounts.IAccountManagerFuture? GetAuthToken(Android.Accounts.Account? account, string? authTokenType, Android.OS.Bundle? options, Android.App.Activity? activity, Android.Accounts.IAccountManagerCallback? callback, Android.OS.Handler? handler);
[<Android.Runtime.Register("getAuthToken", "(Landroid/accounts/Account;Ljava/lang/String;Landroid/os/Bundle;Landroid/app/Activity;Landroid/accounts/AccountManagerCallback;Landroid/os/Handler;)Landroid/accounts/AccountManagerFuture;", "GetGetAuthToken_Landroid_accounts_Account_Ljava_lang_String_Landroid_os_Bundle_Landroid_app_Activity_Landroid_accounts_AccountManagerCallback_Landroid_os_Handler_Handler")>]
[<Android.Runtime.RequiresPermission("android.permission.USE_CREDENTIALS")>]
abstract member GetAuthToken : Android.Accounts.Account * string * Android.OS.Bundle * Android.App.Activity * Android.Accounts.IAccountManagerCallback * Android.OS.Handler -> Android.Accounts.IAccountManagerFuture
override this.GetAuthToken : Android.Accounts.Account * string * Android.OS.Bundle * Android.App.Activity * Android.Accounts.IAccountManagerCallback * Android.OS.Handler -> Android.Accounts.IAccountManagerFuture

參數

account
Account

要取得認證權杖的帳號

authTokenType
String

認證憑證類型(依賴認證器的字串憑證)不得為空

options
Bundle

驗證器專用的請求選項,可能為空或空

activity
Activity

Activity啟動新的認證器定義子活動以提示使用者輸入密碼的上下文;僅用於呼叫 startActivity(;;)不得為空。

callback
IAccountManagerCallback

請求完成時回調以呼叫,無回撥則為 null

handler
Handler

Handler 識別回調執行緒,主執行緒為 null

傳回

一個AccountManagerFuture會解析為包含以下欄位的 Bundle:<ul<>li#KEY_ACCOUNT_NAME> - 你提供的<帳號名稱 li>#KEY_ACCOUNT_TYPE - 帳號<類型 li>#KEY_AUTHTOKEN - 你想要<的認證代幣 /ul>

        (Other authenticator-specific values may be returned.)  If an auth token
        could not be fetched, <code data-dev-comment-type="c">AccountManagerFuture#getResult()</code> throws:
        &lt;ul&gt;
        &lt;li&gt; <code data-dev-comment-type="c">AuthenticatorException</code> if the authenticator failed to respond
        &lt;li&gt; <code data-dev-comment-type="c">OperationCanceledException</code> if the operation is canceled for
             any reason, incluidng the user canceling a credential request
        &lt;li&gt; <code data-dev-comment-type="c">IOException</code> if the authenticator experienced an I/O problem
             creating a new auth token, usually because of network trouble
        &lt;/ul&gt;
        If the account is no longer present on the device, the return value is
        authenticator-dependent.  The caller should verify the validity of the
        account before requesting an auth token.
屬性

備註

會取得特定帳號指定的認證憑證,必要時會提示使用者輸入憑證。 此方法適用於在前景運行的應用程式,當需要直接向使用者索取密碼時。

如果先前產生的認證令牌為該帳號和類型快取,則會回傳該權杖。 否則,若有儲存的密碼可用,則會將其送回伺服器以產生新的認證令牌。 否則,使用者會被要求輸入密碼。

有些驗證器擁有 auth token <em>類型</em>,其值依賴於驗證器。 有些服務會使用不同類型的令牌來存取不同功能——例如,Google 會使用不同的認證令牌來存取同一帳號的 Gmail 和 Google 日曆。

<b>注意:</b> 若目標是在 API 22 級及之前運作,則需取得USE_CREDENTIALS權限。 請參閱 API 等級 22 的相關文件。

此方法可從任何執行緒呼叫,但回傳 AccountManagerFuture 的程式碼不得用於主執行緒。

Java 文件 android.accounts.AccountManager.getAuthToken(android.accounts.Account, java.lang.String, android.os.Bundle, android.app.Activity, android.accounts.AccountManagerCallback<android.os.Bundle>, android.os.Handler)。

本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。

適用於

GetAuthToken(Account, String, Bundle, Boolean, IAccountManagerCallback, Handler)

會獲得特定帳號指定類型的認證令牌,若使用者必須輸入憑證,則可選擇性地發出通知。

[Android.Runtime.Register("getAuthToken", "(Landroid/accounts/Account;Ljava/lang/String;Landroid/os/Bundle;ZLandroid/accounts/AccountManagerCallback;Landroid/os/Handler;)Landroid/accounts/AccountManagerFuture;", "GetGetAuthToken_Landroid_accounts_Account_Ljava_lang_String_Landroid_os_Bundle_ZLandroid_accounts_AccountManagerCallback_Landroid_os_Handler_Handler")]
[Android.Runtime.RequiresPermission("android.permission.USE_CREDENTIALS")]
public virtual Android.Accounts.IAccountManagerFuture? GetAuthToken(Android.Accounts.Account? account, string? authTokenType, Android.OS.Bundle? options, bool notifyAuthFailure, Android.Accounts.IAccountManagerCallback? callback, Android.OS.Handler? handler);
[<Android.Runtime.Register("getAuthToken", "(Landroid/accounts/Account;Ljava/lang/String;Landroid/os/Bundle;ZLandroid/accounts/AccountManagerCallback;Landroid/os/Handler;)Landroid/accounts/AccountManagerFuture;", "GetGetAuthToken_Landroid_accounts_Account_Ljava_lang_String_Landroid_os_Bundle_ZLandroid_accounts_AccountManagerCallback_Landroid_os_Handler_Handler")>]
[<Android.Runtime.RequiresPermission("android.permission.USE_CREDENTIALS")>]
abstract member GetAuthToken : Android.Accounts.Account * string * Android.OS.Bundle * bool * Android.Accounts.IAccountManagerCallback * Android.OS.Handler -> Android.Accounts.IAccountManagerFuture
override this.GetAuthToken : Android.Accounts.Account * string * Android.OS.Bundle * bool * Android.Accounts.IAccountManagerCallback * Android.OS.Handler -> Android.Accounts.IAccountManagerFuture

參數

account
Account

要取得認證權杖的帳號

authTokenType
String

認證憑證類型(依賴認證器的字串憑證)不得為空

options
Bundle

驗證器專用的請求選項,可能為空或空

notifyAuthFailure
Boolean

True 是新增通知,必要時提示使用者輸入密碼,false 則留給來電者

callback
IAccountManagerCallback

請求完成時回調以呼叫,無回撥則為 null

handler
Handler

Handler 識別回調執行緒,主執行緒為 null

傳回

成功AccountManagerFuture時會解析為包含以下欄位的 Bundle:<ul<>li#KEY_ACCOUNT_NAME> - 你提供的<帳號名稱 li>#KEY_ACCOUNT_TYPE - 帳號<類型 li>#KEY_AUTHTOKEN - 你想要<的認證代幣 /ul>

        (Other authenticator-specific values may be returned.)  If the user
        must enter credentials, the returned Bundle contains only
        <code data-dev-comment-type="c">#KEY_INTENT</code> with the <code data-dev-comment-type="c">Intent</code> needed to launch a prompt.

        If an error occurred, <code data-dev-comment-type="c">AccountManagerFuture#getResult()</code> throws:
        &lt;ul&gt;
        &lt;li&gt; <code data-dev-comment-type="c">AuthenticatorException</code> if the authenticator failed to respond
        &lt;li&gt; <code data-dev-comment-type="c">OperationCanceledException</code> if the operation is canceled for
             any reason, incluidng the user canceling a credential request
        &lt;li&gt; <code data-dev-comment-type="c">IOException</code> if the authenticator experienced an I/O problem
             creating a new auth token, usually because of network trouble
        &lt;/ul&gt;
        If the account is no longer present on the device, the return value is
        authenticator-dependent.  The caller should verify the validity of the
        account before requesting an auth token.
屬性

備註

會獲得特定帳號指定類型的認證令牌,若使用者必須輸入憑證,則可選擇性地發出通知。 此方法適用於背景任務與服務,使用者不應立即被密碼提示打斷。

如果先前產生的認證令牌為該帳號和類型快取,則會回傳該權杖。 否則,若有儲存的密碼可用,則會將其送回伺服器以產生新的認證令牌。 否則會回傳 an Intent ,啟動時會提示使用者輸入密碼。 如果設定了 notifyAuthFailure,也會產生一個狀態列通知,並以相同的意圖通知,提醒使用者某個時候需要輸入密碼。

在這種情況下,你可能需要等用戶回應,這可能需要數小時、數天甚至永遠。 當使用者回應並提供新密碼時,帳號管理員會廣播 #LOGIN_ACCOUNTS_CHANGED_ACTION 意圖,並通知 OnAccountsUpdateListener 哪些應用程式可以使用重新嘗試。

如果 notifyAuthFailure 未設定,應用程式必須在某個時候啟動回傳的 Intent。 無論如何,這個通話的結果不會等待使用者行動。

有些驗證器擁有 auth token <em>類型</em>,其值依賴於驗證器。 有些服務會使用不同類型的令牌來存取不同功能——例如,Google 會使用不同的認證令牌來存取同一帳號的 Gmail 和 Google 日曆。

此方法可從任何執行緒呼叫,但回傳 AccountManagerFuture 的程式碼不得用於主執行緒。

<b>注意:</b> 若目標是在 API 22 級及之前運作,則需取得USE_CREDENTIALS權限。 請參閱 API 等級 22 的相關文件。

Java 文件 android.accounts.AccountManager.getAuthToken(android.accounts.Account, java.lang.String, android.os.Bundle, boolean, android.accounts.AccountManagerCallback<android.os.Bundle>, android.os.Handler)。

本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。

適用於