UserAuthenticationOperation Class

异步获取用户的标识及对应的票证和属性。

语法


var userAuthenticationOperation = promise.operation;

特性

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

成员

UserAuthenticationOperation类 具有以下类型的成员:

方法

The UserAuthenticationOperation 类 具有以下方法。 使用 C#、Visual Basic 和 C++,它还可以继承以下内容中的方法 Object 类.

方法描述
Cancel Requests the cancellation of the operation.
Close Requests that work associated with the operation should terminate.
GetResults Returns a UserIdentity object that contains information about the user.

 

属性

UserAuthenticationOperation类 具有以下属性。

属性访问类型描述

Completed

读取/写入Gets or sets a handler that's called when the operation completes.

ErrorCode

只读Gets the error code should the operation fail.

Id

只读Gets a unique identifier that represents the operation.

Status

只读Gets the current status of the operation.

 

备注

Windows Phone 8

此 API 不实现,但是调用时会引发异常。请参见 Windows Phone 运行时 API

示例

以下示例显示如何指定用于对 Live 用户进行身份验证的访问和策略。


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