Share via


OnlineIdAuthenticator 類別

定義

提供應用程式能夠啟動驗證要求,以取得 JavaScript 物件標記法 (JSON) 權杖,以搭配您的服務使用,或要求票證,以用來取得使用者已同意使用 Live ConnectAPI 的應用程式資料。

在傳統型應用程式中,在以顯示 UI 的方式使用這個類別的實例之前,您必須將物件與其擁有者的視窗控制碼產生關聯。 如需詳細資訊和程式碼範例,請參閱 顯示相依于 CoreWindow 的 WinRT UI 物件

注意

如果您要開發Windows 10或更新版本,請改用Windows.Security.Authentication.Web.Core API。 如需詳細資訊,請參閱 Web 帳戶管理員

public ref class OnlineIdAuthenticator sealed
/// [Windows.Foundation.Metadata.Activatable(65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class OnlineIdAuthenticator final
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
class OnlineIdAuthenticator final
[Windows.Foundation.Metadata.Activatable(65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class OnlineIdAuthenticator
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
public sealed class OnlineIdAuthenticator
function OnlineIdAuthenticator()
Public NotInheritable Class OnlineIdAuthenticator
繼承
Object Platform::Object IInspectable OnlineIdAuthenticator
屬性

Windows 需求

裝置系列
Windows 10 (已於 10.0.10240.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)

範例

下列範例示範如何處理使用者驗證要求。

function signIn() {
    var authenticator = new Windows.Security.Authentication.OnlineId.OnlineIdAuthenticator();
    var serviceTicketRequest = new Windows.Security.Authentication.OnlineId.OnlineIdServiceTicketRequest(
        "wl.basic wl.contacts_photos wl.calendars", "DELEGATION");

    sdkSample.displayStatus("Signing in...");

    authenticator.authenticateUserAsync(serviceTicketRequest)
        .done(function (authResult) {

            if ((authResult.tickets.size == 1) && (authResult.tickets[0].errorCode == 0)) {
                sdkSample.isSignedIn = true;
                sdkSample.displayStatus("Authorization succeeded.");
                sdkSample.accessToken = authResult.tickets[0];
                sdkSample.canSignOut = authenticator.canSignOut;
            }
        },

            function (authStatus) {
                if (authStatus && (authStatus.name !== "Canceled")) {
                    showErrorMessage("Autorization failed: " + authStatus.message);
                } else {
                    sdkSample.displayStatus("");
                }
                    showAccountStatus();
                });
}

建構函式

OnlineIdAuthenticator()

建立 OnlineIdAuthenticator的實例。

在傳統型應用程式中,在以顯示 UI 的方式使用這個類別的實例之前,您必須將物件與其擁有者的視窗控制碼產生關聯。 如需詳細資訊和程式碼範例,請參閱 顯示相依于 CoreWindow 的 WinRT UI 物件

注意

如果您要開發Windows 10或更新版本,請改用Windows.Security.Authentication.Web.Core API。 如需詳細資訊,請參閱 Web 帳戶管理員

屬性

ApplicationId

GUID傳回應用程式的識別碼。

注意

如果您要針對Windows 10或更新版本進行開發,請改用Windows.Security.Authentication.Web.Core API。 如需詳細資訊,請參閱 Web 帳戶管理員

AuthenticatedSafeCustomerId

傳回已成功驗證應用程式之使用者的識別碼。

注意

如果您要針對Windows 10或更新版本進行開發,請改用Windows.Security.Authentication.Web.Core API。 如需詳細資訊,請參閱 Web 帳戶管理員

CanSignOut

指出使用者是否可以登出應用程式,以及是否要在應用程式中顯示登出連結。

注意

如果您要針對Windows 10或更新版本進行開發,請改用Windows.Security.Authentication.Web.Core API。 如需詳細資訊,請參閱 Web 帳戶管理員

方法

AuthenticateUserAsync(IIterable<OnlineIdServiceTicketRequest>, CredentialPromptType)

使用多個 OnlineIdServiceTicketRequests 啟動非同步驗證要求,並提供設定 CredentialPromptType 以取得票證來控制使用者體驗的能力。 如果使用者使用 Microsoft 帳戶登入 Windows 8 系統,此使用者將會用於驗證要求。

注意

如果您要針對Windows 10或更新版本進行開發,請改用Windows.Security.Authentication.Web.Core API。 如需詳細資訊,請參閱 Web 帳戶管理員

AuthenticateUserAsync(OnlineIdServiceTicketRequest)

視需要收集認證或同意並取得票證,以一 個 OnlineIdServiceTicketRequest 啟動非同步驗證要求。 如果使用者使用 Microsoft 帳戶登入 Windows 8 系統,此使用者將會用於驗證要求。

注意

如果您要針對Windows 10或更新版本進行開發,請改用Windows.Security.Authentication.Web.Core API。 如需詳細資訊,請參閱 Web 帳戶管理員

SignOutUserAsync()

允許使用者登出您的應用程式。

注意

如果您要針對Windows 10或更新版本進行開發,請改用Windows.Security.Authentication.Web.Core API。 如需詳細資訊,請參閱 Web 帳戶管理員

適用於