共用方式為


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)

通知啟動的應用程式發生錯誤,而且需要使用者互動才能繼續作業。

適用於

另請參閱