OnlineIdAuthenticator Class

可讓應用程式啟動驗證要求,以取得 JavaScript 物件標記法 (JSON) 語彙基元(以搭配您的服務使用)或要求票證(該票證可用來為使用 Live Connect 應用程式開發介面的應用程式取得使用者已同意給予的資料)。

語法


var onlineIdAuthenticator = new Windows.Security.Authentication.OnlineId.OnlineIdAuthenticator();

屬性

[MarshalingBehavior(Agile)]
[Threading(Both)]
[Version(0x06020000)]

成員

OnlineIdAuthenticator類別 有這些類型的成員:

建構函式

OnlineIdAuthenticator類別 有這些建構函式。

建構函式說明
OnlineIdAuthenticator Creates an instance of the OnlineIdAuthenticator.

 

方法

The OnlineIdAuthenticator 類別 有這些方法。 使用 C#、Visual Basic 和 C++,也會繼承來自以下項目的方法 Object 類別.

方法說明
AuthenticateUserAsync(IIterable(OnlineIdServiceTicketRequest), CredentialPromptType) Starts the async authentication request with multiple OnlineIdServiceTicketRequests and provides the ability to control the user experience by setting the CredentialPromptType to get the tickets. If a user is signed into a Windows 8 system with a Microsoft account, this user will be used for the authentication request.
AuthenticateUserAsync(OnlineIdServiceTicketRequest) Starts the async authentication request with one OnlineIdServiceTicketRequest. If a user is signed into a Windows 8 system with a Microsoft account, this user will be used for the authentication request.
SignOutUserAsync Allows users to sign out of your app.

 

屬性

OnlineIdAuthenticator類別 有這些內容。

屬性存取類型說明

ApplicationId

讀取/寫入Returns the ID of the application as a GUID.

AuthenticatedSafeCustomerId

唯讀Returns the ID of a user who has been successfully authenticated for your app.

CanSignOut

唯讀Indicates whether a user can sign out of the app, and whether to show the sign out link in the app.

 

範例

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


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();
                });
}

需求

最低支援的用戶端

Windows 8 [僅限 Windows 市集應用程式]

最低支援的伺服器

Windows Server 2012 [僅限 Windows 市集應用程式]

最低支援的電話

Windows Phone 8

命名空間

Windows.Security.Authentication.OnlineId
Windows::Security::Authentication::OnlineId [C++]

中繼資料

Windows.winmd

 

 

顯示:
© 2014 Microsoft