Delen via


WebAuthenticationCoreManager.FindSystemAccountProviderAsync Method

Definition

Overloads

FindSystemAccountProviderAsync(String)

Asynchronously attempts to find a web account provider for device-wide authentication.

FindSystemAccountProviderAsync(String, String)

Asynchronously attempts to find a web account provider for device-wide authentication.

FindSystemAccountProviderAsync(String, String, User)

Asynchronously attempts to find a web account provider for device-wide authentication.

FindSystemAccountProviderAsync(String)

Asynchronously attempts to find a web account provider for device-wide authentication.

public:
 static IAsyncOperation<WebAccountProvider ^> ^ FindSystemAccountProviderAsync(Platform::String ^ webAccountProviderId);
/// [Windows.Foundation.Metadata.Overload("FindSystemAccountProviderAsync")]
/// [Windows.Foundation.Metadata.RemoteAsync]
 static IAsyncOperation<WebAccountProvider> FindSystemAccountProviderAsync(winrt::hstring const& webAccountProviderId);
[Windows.Foundation.Metadata.Overload("FindSystemAccountProviderAsync")]
[Windows.Foundation.Metadata.RemoteAsync]
public static IAsyncOperation<WebAccountProvider> FindSystemAccountProviderAsync(string webAccountProviderId);
function findSystemAccountProviderAsync(webAccountProviderId)
Public Shared Function FindSystemAccountProviderAsync (webAccountProviderId As String) As IAsyncOperation(Of WebAccountProvider)

Parameters

webAccountProviderId
String

Platform::String

winrt::hstring

The Id of the web account provider to find.

Returns

An asynchronous find operation. On successful completion, contains a WebAccountProvider object representing the found web account provider.

Attributes

Windows requirements

Device family
Windows 10, version 1803 (introduced in 10.0.17134.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v6.0)

Applies to

FindSystemAccountProviderAsync(String, String)

Asynchronously attempts to find a web account provider for device-wide authentication.

public:
 static IAsyncOperation<WebAccountProvider ^> ^ FindSystemAccountProviderAsync(Platform::String ^ webAccountProviderId, Platform::String ^ authority);
/// [Windows.Foundation.Metadata.Overload("FindSystemAccountProviderWithAuthorityAsync")]
/// [Windows.Foundation.Metadata.RemoteAsync]
 static IAsyncOperation<WebAccountProvider> FindSystemAccountProviderAsync(winrt::hstring const& webAccountProviderId, winrt::hstring const& authority);
[Windows.Foundation.Metadata.Overload("FindSystemAccountProviderWithAuthorityAsync")]
[Windows.Foundation.Metadata.RemoteAsync]
public static IAsyncOperation<WebAccountProvider> FindSystemAccountProviderAsync(string webAccountProviderId, string authority);
function findSystemAccountProviderAsync(webAccountProviderId, authority)
Public Shared Function FindSystemAccountProviderAsync (webAccountProviderId As String, authority As String) As IAsyncOperation(Of WebAccountProvider)

Parameters

webAccountProviderId
String

Platform::String

winrt::hstring

The Id of the web account provider to find.

authority
String

Platform::String

winrt::hstring

The authority of the web account provider to find.

Returns

An asynchronous find operation. On successful completion, contains a WebAccountProvider object representing the found web account provider.

Attributes

Windows requirements

Device family
Windows 10, version 1803 (introduced in 10.0.17134.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v6.0)

Examples

The following is an example of this special case of device-wide token retrieval.

// create a WebTokenRequest with device-wide authentication
WebTokenRequest CreateWebTokenRequestForAad(WebAccountProvider provider){
    // check if the ID provider allows system-wide scope, and construct token request accordingly:
    return new WebTokenRequest(
        provider,
        provider.IsSystemProvider ? "systemInfo" : "userInfo",
        "<InsertClientID>");
    )
}

// retrieve a device-wide auth token for Azure Active Directory
string GetAadToken() {
    var provider = WebAuthenticationCoreManager.FindSystemAccountProviderAsync(
        "https://login.microsoft.com","organizations");
    var request = CreateWebTokenRequestForAad(provider);
    var result = WebAuthenticationCoreManager.GetTokenSilentlyAsync(request);

    // handle the request result in the usual way.
    if (result.ResponseStatus == WebTokenRequestStatus.Success){ 
        return result.ResponseData[0].Token; 
    } else { 
        throw new Exception(result.ResponseError.ErrorMessage); 
    }     
} 

Remarks

The device token feature is intended for cases in which a service needs to connect to cloud resources before a user ever signs into the device (for example, in out-of-box experiences where there are System Center Configuration Manager (SCCM) policies that must be applied right away). Only first-party ID providers (Xbox, MSA, AAD) allow device-wide tokens; other ID providers do not.

See also

Applies to

FindSystemAccountProviderAsync(String, String, User)

Asynchronously attempts to find a web account provider for device-wide authentication.

public:
 static IAsyncOperation<WebAccountProvider ^> ^ FindSystemAccountProviderAsync(Platform::String ^ webAccountProviderId, Platform::String ^ authority, User ^ user);
/// [Windows.Foundation.Metadata.Overload("FindSystemAccountProviderWithAuthorityForUserAsync")]
/// [Windows.Foundation.Metadata.RemoteAsync]
 static IAsyncOperation<WebAccountProvider> FindSystemAccountProviderAsync(winrt::hstring const& webAccountProviderId, winrt::hstring const& authority, User const& user);
[Windows.Foundation.Metadata.Overload("FindSystemAccountProviderWithAuthorityForUserAsync")]
[Windows.Foundation.Metadata.RemoteAsync]
public static IAsyncOperation<WebAccountProvider> FindSystemAccountProviderAsync(string webAccountProviderId, string authority, User user);
function findSystemAccountProviderAsync(webAccountProviderId, authority, user)
Public Shared Function FindSystemAccountProviderAsync (webAccountProviderId As String, authority As String, user As User) As IAsyncOperation(Of WebAccountProvider)

Parameters

webAccountProviderId
String

Platform::String

winrt::hstring

The Id of the web account provider to find.

authority
String

Platform::String

winrt::hstring

The authority of the web account provider to find.

user
User

The user associated with the web account provider to find.

Returns

An asynchronous find operation. On successful completion, contains a WebAccountProvider object representing the found web account provider.

Attributes

Windows requirements

Device family
Windows 10, version 1803 (introduced in 10.0.17134.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v6.0)

Applies to