WebAccountProviderGetTokenSilentOperation 类

定义

表示以无提示方式获取令牌的操作。

public ref class WebAccountProviderGetTokenSilentOperation sealed : IWebAccountProviderSilentReportOperation, IWebAccountProviderTokenOperation
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class WebAccountProviderGetTokenSilentOperation final : IWebAccountProviderSilentReportOperation, IWebAccountProviderTokenOperation
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class WebAccountProviderGetTokenSilentOperation : IWebAccountProviderSilentReportOperation, IWebAccountProviderTokenOperation
Public NotInheritable Class WebAccountProviderGetTokenSilentOperation
Implements IWebAccountProviderSilentReportOperation, IWebAccountProviderTokenOperation
继承
Object Platform::Object IInspectable WebAccountProviderGetTokenSilentOperation
属性
实现

Windows 要求

设备系列
Windows 10 (在 10.0.10240.0 中引入)
API contract
Windows.Foundation.UniversalApiContract (在 v1.0 中引入)

示例

下面演示如何以无提示方式处理获取令牌操作:

void HandleGetTokenSilently(WebAccountProviderGetTokenSilentOperation operation)
{
    try
    {
        WebProviderTokenRequest webProviderTokenRequest = operation.ProviderRequest;
        WebTokenRequest tokenRequest = webProviderTokenRequest.ClientRequest;

        // authenticate silently with the tokenrequest and get back an access token
        WebTokenResponse response = new WebTokenResponse(accessToken); 

        // Add any desired properties to send with the response
        response.Properties.Add("responsePropertyKey1", "responesPropertyValue1");
        response.Properties.Add("responsePropertyKey2", "responsePropertyValue2");

        // send the response
        WebProviderTokenResponse providerResponse = new WebProviderTokenResponse(response, 
                                                        DateTimeOffset.Now.AddHours(1));
        IList<WebProviderTokenResponse> responses = operation.Responses;
        responses.Add(providerResponse);
        operation.ReportCompleted();
    }
    catch (Exception ex)
    {
        WebProviderError error = new WebProviderError(ERROR_CODE, ex.Message);
        operation.ReportError(error);
    }
}

属性

CacheExpirationTime

获取或设置缓存过期时间。

Kind

获取 Web 帐户提供程序操作的类型。

ProviderRequest

获取 Web 提供程序令牌请求。

ProviderResponses

获取 Web 提供程序令牌响应。

方法

ReportCompleted()

通知激活应用操作已成功完成。

ReportError(WebProviderError)

通知激活应用操作遇到错误。

ReportUserInteractionRequired()

通知激活应用需要用户交互才能继续操作。

ReportUserInteractionRequired(WebProviderError)

通知激活应用发生了错误,并且需要用户交互才能继续操作。

适用于

另请参阅