Web 帳戶管理員Web Account Manager

本文說明如何使用 AccountsSettingsPane 將通用 WINDOWS 平臺 (UWP) 應用程式連線到外部識別提供者(例如 Microsoft 或 Facebook),並使用 Windows 10 Web 帳戶管理員 api。This article describes how to use the AccountsSettingsPane to connect your Universal Windows Platform (UWP) app to external identity providers, like Microsoft or Facebook, using the Windows 10 Web Account Manager APIs. 您將了解如何要求使用者的權限以使用其 Microsoft 帳戶,取得存取權杖,並利用它來執行基本操作 (例如取得個人檔案資料,或上傳檔案到他們的 OneDrive 帳戶)。You'll learn how to request a user's permission to use their Microsoft account, obtain an access token, and use it to perform basic operations (like get profile data or upload files to their OneDrive account). 取得使用者權限的步驟,與透過任何支援 Web 帳戶管理員的身分識別提供者存取類似。The steps are similar for getting user permission and access with any identity provider that supports the Web Account Manager.

注意

如需完整的程式碼範例,請參閱 GitHub 上的 WebAccountManagement 範例For a complete code sample, see the WebAccountManagement sample on GitHub.

開始設定Get set up

首先,在 Visual Studio 中建立新的空白應用程式。First, create a new, blank app in Visual Studio.

其次,為了要連線到身分識別提供者,您必須將應用程式與市集建立關聯。Second, in order to connect to identity providers, you'll need to associate your app with the Store. 若要這樣做,請以滑鼠右鍵按一下您的專案,選擇 [存放區 > 關聯應用程式與存放區],然後依照嚮導的指示進行。To do this, right click your project, choose Store > Associate app with the store, and follow the wizard's instructions.

接下來,建立非常基本的 UI,並在其中包含一個簡單的 XAML 按鈕以及兩個文字方塊。Third, create a very basic UI consisting of a simple XAML button and two text boxes.

<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
    <Button x:Name="LoginButton" Content="Log in" Click="LoginButton_Click" />
    <TextBlock x:Name="UserIdTextBlock"/>
    <TextBlock x:Name="UserNameTextBlock"/>
</StackPanel>

接著在程式碼後置中將事件處理常式附加至該按鈕:And an event handler attached to your button in the code-behind:

private void LoginButton_Click(object sender, RoutedEventArgs e)
{   
}

最後,新增下列命名空間,如此您稍後就無須擔心任何參照問題:Lastly, add the following namespaces so you don't have to worry about any reference issues later:

using System;
using Windows.Security.Authentication.Web.Core;
using Windows.System;
using Windows.UI.ApplicationSettings;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.Data.Json;
using Windows.UI.Xaml.Navigation;
using Windows.Web.Http;

顯示帳戶設定窗格Show the accounts settings pane

系統提供稱為 AccountsSettingsPane 的內建使用者介面,用來管理身分識別提供者和 Web 帳戶。The system provides a built-in user interface for managing identity providers and web accounts called AccountsSettingsPane. 您可以透過下列方式顯示它:You can show it like this:

private void LoginButton_Click(object sender, RoutedEventArgs e)
{
    AccountsSettingsPane.Show(); 
}

當您執行應用程式並按一下 [登入] 按鈕,它應該會顯示空白視窗。If you run your app and click the "Log in" button, it should display an empty window.

[選擇未列出帳戶的帳戶] 視窗的螢幕擷取畫面。

窗格之所以為空白,是因為系統僅提供 UI 殼層 - 開發人員必須以程式設計方式將身分識別提供者填入窗格。The pane is empty because the system only provides a UI shell - it's up to the developer to programatically populate the pane with the identity providers.

提示

(選擇性)您可以使用 ShowAddAccountAsync (而不是 Show)來查詢作業的狀態,這會傳回 IAsyncActionOptionally, you can use ShowAddAccountAsync instead of Show, which will return an IAsyncAction, to query for the status of the operation.

註冊 AccountCommandsRequestedRegister for AccountCommandsRequested

若要將命令加入到窗格中,我們可以從註冊 AccountCommandsRequested 事件處理常式開始。To add commands to the pane, we start by registering for the AccountCommandsRequested event handler. 如此一來,當使用者要求查看窗格時,系統就會執行組建邏輯 (例如,按一下) 的 XAML 按鈕。This tells the system to run our build logic when the user asks to see the pane (for example, clicks our XAML button).

在程式碼後置中,覆寫 OnNavigatedTo 和 OnNavigatedFrom 事件,然後將下列程式碼新增到它們︰In your code behind, override the OnNavigatedTo and OnNavigatedFrom events and add the following code to them:

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    AccountsSettingsPane.GetForCurrentView().AccountCommandsRequested += BuildPaneAsync; 
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
    AccountsSettingsPane.GetForCurrentView().AccountCommandsRequested -= BuildPaneAsync; 
}

使用者不會非常頻繁地與帳戶互動,因此以這種方式註冊和解除註冊事件處理常式有助於防止記憶體流失。Users don't interact with accounts very often, so registering and deregistering your event handler in this fashion helps prevent memory leaks. 如此一來,當使用者有很大機率會要求查看您的自訂窗格時 (因為他們正位於 [設定] 或 [登入] 頁面),該窗格只會存在於記憶體中。This way, your customized pane is only in memory when there's a high chance a user is going to ask for it (because they're on a "settings" or "login" page, for example).

建置帳戶設定窗格Build the account settings pane

每當顯示 AccountsSettingsPane 時,便會呼叫 BuildPaneAsync 方法。The BuildPaneAsync method is called whenever the AccountsSettingsPane is shown. 這是我們將放置程式碼以自訂在窗格中顯示之命令的位置。This is where we'll put the code to customize the commands shown in the pane.

從取得延遲開始。Start by obtaining a deferral. 這會告訴系統延遲顯示 AccountsSettingsPane,直到我們完成建置為止。This tells the system to delay showing the AccountsSettingsPane until we're finished building it.

private async void BuildPaneAsync(AccountsSettingsPane s,
    AccountsSettingsPaneCommandsRequestedEventArgs e)
{
    var deferral = e.GetDeferral();
        
    deferral.Complete(); 
}

接下來,使用 WebAuthenticationCoreManager.FindAccountProviderAsync 方法取得提供者。Next, get a provider using the WebAuthenticationCoreManager.FindAccountProviderAsync method. 提供者的 URL 會隨著提供者而有所不同,您可以在提供者的文件中找到。The URL for the provider varies based on the provider and can be found in the provider's documentation. 若為 Microsoft 帳戶和 Azure Active Directory,則為 "HTTPs : //login.microsoft.com"。For Microsoft Accounts and Azure Active Directory, it's "https://login.microsoft.com".

private async void BuildPaneAsync(AccountsSettingsPane s,
    AccountsSettingsPaneCommandsRequestedEventArgs e)
{
    var deferral = e.GetDeferral();
        
    var msaProvider = await WebAuthenticationCoreManager.FindAccountProviderAsync(
        "https://login.microsoft.com", "consumers"); 
        
    deferral.Complete(); 
}

請注意,我們也會傳送字串「consumers」到選擇性的 authority 參數。Notice that we also pass the string "consumers" to the optional authority parameter. 這是因為 Microsoft 提供兩種不同類型的驗證 - 針對「consumers (消費者)」的 Microsoft 帳戶 (MSA),針對「organizations (組織)」的 Azure Active Directory (AAD)。This is because Microsoft provides two different types of authentication - Microsoft Accounts (MSA) for "consumers", and Azure Active Directory (AAD) for "organizations". 「consumers (消費者)」授權表示我們想要 MSA 選項。The "consumers" authority indicates we want the MSA option. 如果您是在開發企業應用程式,請改為使用「organizations (組織)」字串。If you're developing an enterprise app, use the string "organizations" instead.

最後,建立新的**WebAccountProviderCommand** ,如下所示,將提供者新增至AccountsSettingsPaneFinally, add the provider to the AccountsSettingsPane by creating a new WebAccountProviderCommand like this:

private async void BuildPaneAsync(AccountsSettingsPane s,
    AccountsSettingsPaneCommandsRequestedEventArgs e)
{
    var deferral = e.GetDeferral();

    var msaProvider = await WebAuthenticationCoreManager.FindAccountProviderAsync(
        "https://login.microsoft.com", "consumers");

    var command = new WebAccountProviderCommand(msaProvider, GetMsaTokenAsync);  

    e.WebAccountProviderCommands.Add(command);

    deferral.Complete(); 
}

我們傳送到新的 WebAccountProviderCommand 的 GetMsaToken 方法還不存在 (我們將在後續步驟中建置),因此目前請放心地將它新增為空白方法。The GetMsaToken method we passed to our new WebAccountProviderCommand doesn't exist yet (we'll build that in the next step), so feel free to add it as an empty method for now.

執行上述的程式碼,您的窗格看起來應該如下:Run the above code and your pane should look something like this:

[選擇帳戶] 視窗的螢幕擷取畫面,其中列出帳戶。

要求權杖Request a token

一旦我們在 AccountsSettingsPane 中顯示 Microsoft 帳戶選項,就必須處理使用者選取它時所發生的情況。Once we have the Microsoft Account option displaying in the AccountsSettingsPane, we need to handle what happens when the user selects it. 我們已註冊當使用者選擇使用他們的 Microsoft 帳戶登入時要引發的 GetMsaToken 方法,因此我們將在該處取得權杖。We registered our GetMsaToken method to fire when the user chooses to log in with their Microsoft Account, so we'll obtain the token there.

若要取得權杖,請使用 RequestTokenAsync 方法,如下所示:To obtain a token, use the RequestTokenAsync method like this:

private async void GetMsaTokenAsync(WebAccountProviderCommand command)
{
    WebTokenRequest request = new WebTokenRequest(command.WebAccountProvider, "wl.basic");
    WebTokenRequestResult result = await WebAuthenticationCoreManager.RequestTokenAsync(request);
}

在此範例中,我們會將字串 "wl. basic" 傳遞至 範圍 參數。In this example, we pass the string "wl.basic" to the scope parameter. 範圍代表您從特定使用者提供的服務要求所要求的資訊類型。Scope represents the type of information you are requesting from the providing service on a specific user. 某些範圍僅提供使用者基本資訊的存取,例如姓名和電子郵件地址,有些範圍可能授與敏感資訊的存取權,像是使用者的相片或電子郵件收件匣。Certain scopes provide access only to a user's basic information, like name and email address, while other scopes might grant access to sensitive information such as the user's photos or email inbox. 一般而言,您的 app 應該使用達成其功能所需的最低權限範圍。Generally, your app should use the least permissive scope necessary to achieve its function. 服務提供者會提供文件,說明需要哪些範圍以取得權杖來使用他們的服務。Service providers will provide documentation on which scopes are needed to get tokens for use with their services.

提示

(選擇性)如果您的應用程式使用登入提示 (將預設電子郵件地址填入 [使用者] 欄位) 或其他與登入體驗相關的特殊屬性,請在 [ WebTokenRequest AppProperties ] 屬性中列出。Optionally, if your app uses a login hint (to populate the user field with a default email address) or other special property related to the sign-in experience, list it in the WebTokenRequest.AppProperties property. 這會導致系統在快取 web 帳戶時忽略該屬性,以避免在快取中發生帳戶不符的情況。This will cause the system to ignore the property when caching the web account, which prevents account mismatches in the cache.

如果您是在開發企業應用程式,您可以連線 Azure Active Directory (AAD) 執行個體,並使用 Microsoft Graph API,而不是使用一般的 MSA 服務。If you're developing an enterprise app, you'll likely want to connect to an Azure Active Directory (AAD) instance and use the Microsoft Graph API instead of regular MSA services. 在這個案例中,請改為使用以下程式碼:In this scenario, use the following code instead:

private async void GetAadTokenAsync(WebAccountProviderCommand command)
{
    string clientId = "your_guid_here"; // Obtain your clientId from the Azure Portal
    WebTokenRequest request = new WebTokenRequest(provider, "User.Read", clientId);
    request.Properties.Add("resource", "https://graph.microsoft.com");
    WebTokenRequestResult result = await WebAuthenticationCoreManager.RequestTokenAsync(request);
}

本文其餘部分會繼續說明 MSA 案例,但 AAD 的程式碼是非常類似的。The rest of this article continues describing the MSA scenario, but the code for AAD is very similar. 如需 AAD/Graph 的詳細資訊,包括 GitHub 的完整範例,請參閱 Microsoft Graph 文件For more info on AAD/Graph, including a full sample on GitHub, see the Microsoft Graph documentation.

使用權杖Use the token

RequestTokenAsync 方法會傳回 WebTokenRequestResult 物件,它包含您要求的結果。The RequestTokenAsync method returns a WebTokenRequestResult object, which contains the results of your request. 如果要求成功,它會包含權杖。If your request was successful, it will contain a token.

private async void GetMsaTokenAsync(WebAccountProviderCommand command)
{
    WebTokenRequest request = new WebTokenRequest(command.WebAccountProvider, "wl.basic");
    WebTokenRequestResult result = await WebAuthenticationCoreManager.RequestTokenAsync(request);
    
    if (result.ResponseStatus == WebTokenRequestStatus.Success)
    {
        string token = result.ResponseData[0].Token; 
    }
}

注意

如果您在要求權杖時收到錯誤,請確定您已將應用程式與 Store 產生關聯,如步驟一所述。If you receive an error when requesting a token, make sure you've associated your app with the Store as described in step one. 如果您略過此步驟,您的應用程式將無法取得權杖。Your app won't be able to get a token if you skipped this step.

一旦您擁有權杖之後,就可以使用它來呼叫您提供者的 API。Once you have a token, you can use it to call your provider's API. 在下列程式碼中,我們將呼叫 使用者資訊 Microsoft Live API 以取得關於使用者的基本資訊,然後將資訊顯示在我們的 UI 中。In the code below, we'll call the user info Microsoft Live API to obtain basic information about the user and display it in our UI. 不過請注意,大多數情況下建議您在取得權杖後立即將它儲存,然後以不同的方法使用它。Note however that in most cases it is recommended that you store the token once obtained and then use it in a separate method.

private async void GetMsaTokenAsync(WebAccountProviderCommand command)
{
    WebTokenRequest request = new WebTokenRequest(command.WebAccountProvider, "wl.basic");
    WebTokenRequestResult result = await WebAuthenticationCoreManager.RequestTokenAsync(request);
    
    if (result.ResponseStatus == WebTokenRequestStatus.Success)
    {
        string token = result.ResponseData[0].Token; 
        
        var restApi = new Uri(@"https://apis.live.net/v5.0/me?access_token=" + token);

        using (var client = new HttpClient())
        {
            var infoResult = await client.GetAsync(restApi);
            string content = await infoResult.Content.ReadAsStringAsync();

            var jsonObject = JsonObject.Parse(content);
            string id = jsonObject["id"].GetString();
            string name = jsonObject["name"].GetString();

            UserIdTextBlock.Text = "Id: " + id; 
            UserNameTextBlock.Text = "Name: " + name;
        }
    }
}

呼叫 REST API 的方式依提供者而有所不同;如需如何使用權杖的詳細資訊,請參閱提供者的 API 文件。How you call various REST APIs varies between providers; see the provider's API documentation for information on how to use your token.

儲存帳戶供未來使用Store the account for future use

權杖對於立即取得使用者的相關資訊非常有用,但它們通常具有不同的壽命 - 例如 MSA 權杖僅在幾個小時內有效。Tokens are useful for immediately obtaining information about a user, but they usually have varying lifespans - MSA tokens, for instance, are only valid for a few hours. 幸運的是,您不需要每次在權杖到期時都重新顯示 AccountsSettingsPaneFortunately, you don't need to re-show the AccountsSettingsPane each time a token expires. 使用者只要授權您的應用程式一次,您就可以儲存使用者的帳戶資訊供以後使用。Once a user has authorized your app once, you can store the user's account information for future use.

若要這樣做,請使用 WebAccount 類別。To do this, use the WebAccount class. WebAccount會透過您用來要求權杖的相同方法傳回:A WebAccount is returned by the same method you used to request the token:

private async void GetMsaTokenAsync(WebAccountProviderCommand command)
{
    WebTokenRequest request = new WebTokenRequest(command.WebAccountProvider, "wl.basic");
    WebTokenRequestResult result = await WebAuthenticationCoreManager.RequestTokenAsync(request);
    
    if (result.ResponseStatus == WebTokenRequestStatus.Success)
    {
        WebAccount account = result.ResponseData[0].WebAccount; 
    }
}

一旦擁有 WebAccount 執行個體之後,您就可以輕鬆地儲存它。Once you have a WebAccount instance, you can easily store it. 在下列範例中,我們使用 LocalSettings。In the following example, we use LocalSettings. 如需有關使用 LocalSettings 和其他方法儲存使用者資料的詳細資訊,請參閱儲存和擷取應用程式設定和資料For more information on using LocalSettings and other methods to store user data, see Store and retrieve app settings and data.

private async void StoreWebAccount(WebAccount account)
{
    ApplicationData.Current.LocalSettings.Values["CurrentUserProviderId"] = account.WebAccountProvider.Id;
    ApplicationData.Current.LocalSettings.Values["CurrentUserId"] = account.Id; 
}

然後,我們可以使用如下所示的非同步方法,嘗試在背景使用儲存的 WebAccount 取得權杖。Then, we can use an asynchronous method like the following to attempt to obtain a token in the background with the stored WebAccount.

private async Task<string> GetTokenSilentlyAsync()
{
    string providerId = ApplicationData.Current.LocalSettings.Values["CurrentUserProviderId"]?.ToString();
    string accountId = ApplicationData.Current.LocalSettings.Values["CurrentUserId"]?.ToString();

    if (null == providerId || null == accountId)
    {
        return null; 
    }

    WebAccountProvider provider = await WebAuthenticationCoreManager.FindAccountProviderAsync(providerId);
    WebAccount account = await WebAuthenticationCoreManager.FindAccountAsync(provider, accountId);

    WebTokenRequest request = new WebTokenRequest(provider, "wl.basic");

    WebTokenRequestResult result = await WebAuthenticationCoreManager.GetTokenSilentlyAsync(request, account);
    if (result.ResponseStatus == WebTokenRequestStatus.UserInteractionRequired)
    {
        // Unable to get a token silently - you'll need to show the UI
        return null; 
    }
    else if (result.ResponseStatus == WebTokenRequestStatus.Success)
    {
        // Success
        return result.ResponseData[0].Token;
    }
    else
    {
        // Other error 
        return null; 
    }
}

將上述方法放在建置 AccountsSettingsPane 的程式碼正前方。Place the above method just before the code that builds the AccountsSettingsPane. 如果權杖是在背景中取得,則不需要顯示窗格。If the token is obtained in the background, there is no need to show the pane.

private void LoginButton_Click(object sender, RoutedEventArgs e)
{
    string silentToken = await GetMsaTokenSilentlyAsync();

    if (silentToken != null)
    {
        // the token was obtained. store a reference to it or do something with it here.
    }
    else
    {
        // the token could not be obtained silently. Show the AccountsSettingsPane
        AccountsSettingsPane.Show();
    }
}

因為以無訊息方式取得權杖非常簡單,您應該使用此程序在工作階段之間重新整理權杖,而不是快取現有權杖 (因為該權杖隨時可能到期)。Because obtaining a token silently is very simple, you should use this process to refresh your token between sessions rather than caching an existing token (since that token might expire at any time).

注意

上述範例僅涵蓋基本的成功與失敗情況。The example above only covers basic success and fail cases. 您的應用程式應該也要考量特殊案例 (例如使用者撤銷應用程式的權限,或從 Windows 移除帳戶) 並妥善處理。Your app should also account for unusual scenarios (like a user revoking your app's permission or removing their account from Windows, for example) and handle them gracefully.

移除儲存的帳戶Remove a stored account

如果您保留 Web 帳戶,建議您讓使用者能夠將自己的帳戶與您的 app 解除關聯。If you persist a web account, you may want to give your users the ability to disassociate their account with your app. 如此一來,他們就可以有效地「登出」應用程式:在啟動時,將不會再自動載入他們的帳戶資訊。This way, they can effectively "log out" of the app: their account information will no longer be loaded automatically upon launch. 若要這樣做,請先移除儲存空間中的任何儲存的帳戶和提供者資訊。To do this, first remove any saved account and provider information from storage. 接著呼叫 SignOutAsync 以清除快取,並使任何應用程式可能擁有的現有權杖無效。Then call SignOutAsync to clear the cache and invalidate any existing tokens your app may have.

private async Task SignOutAccountAsync(WebAccount account)
{
    ApplicationData.Current.LocalSettings.Values.Remove("CurrentUserProviderId");
    ApplicationData.Current.LocalSettings.Values.Remove("CurrentUserId"); 
    account.SignOutAsync(); 
}

新增不支援 WebAccountManager 的提供者Add providers that don't support WebAccountManager

例如,如果您想要將驗證從服務整合到您的應用程式,但該服務不支援 WebAccountManager-Google + 或 Twitter,您仍然可以手動將該提供者新增至 AccountsSettingsPaneIf you want to integrate authentication from a service into your app but that service doesn't support WebAccountManager - Google+ or Twitter, for example - you can still manually add that provider to the AccountsSettingsPane. 若要這樣做,請建立新的 WebAccountProvider 物件,並提供您自己的名稱及 .png 圖示,然後將它新增到 WebAccountProviderCommands 清單。To do so, create a new WebAccountProvider object and provide your own name and .png icon, then and add it to the WebAccountProviderCommands list. 以下是一些虛設常式程式碼︰Here's some stub code:

private async void BuildPaneAsync(AccountsSettingsPane s, AccountsSettingsPaneCommandsRequestedEventArgs e)
{
   // other code here 

   var twitterProvider = new WebAccountProvider("twitter", "Twitter", new Uri(@"ms-appx:///Assets/twitter-auth-icon.png")); 
   var twitterCmd = new WebAccountProviderCommand(twitterProvider, GetTwitterTokenAsync);
   e.WebAccountProviderCommands.Add(twitterCmd);   
   
   // other code here
}

private async void GetTwitterTokenAsync(WebAccountProviderCommand command)
{
   // Manually handle Twitter login here
}

注意

這僅會將圖示加入到 AccountsSettingsPane,並在按一下圖示時執行您指定的方法 (在此案例中為 GetTwitterTokenAsync)。This only adds an icon to the AccountsSettingsPane and runs the method you specify when the icon is clicked (GetTwitterTokenAsync, in this case). 您必須提供會處理實際驗證的程式碼。You must provide the code that handles the actual authentication. 如需詳細資訊,請參閱 Web 驗證訊息代理程式,其提供使用 REST 服務進行驗證的 helper 方法。For more information, see Web authentication broker, which provides helper methods for authenticating using REST services.

新增自訂標頭Add a custom header

您可以使用 HeaderText 屬性來自訂帳戶設定窗格,如下所示:You can customize the account settings pane using the HeaderText property, like this:

private async void BuildPaneAsync(AccountsSettingsPane s, AccountsSettingsPaneCommandsRequestedEventArgs e)
{
    // other code here 
    
    args.HeaderText = "MyAwesomeApp works best if you're signed in.";   
    
    // other code here
}

[選擇未列出帳戶的帳戶] 視窗的螢幕擷取畫面,以及指出我的絕佳應用程式在您登入時最適合的訊息。

請勿過度使用標頭文字;請將它維持簡短易記。Don't go overboard with header text; keep it short and sweet. 如果您的登入程序很複雜,而您需要顯示更多資訊,請使用自訂連結將使用者連結到另一個頁面。If your login process is complicated and you need to display more information, link the user to a separate page using a custom link.

您可以將自訂命令加入到 AccountsSettingsPane,該命令在支援的 WebAccountProviders 底下會顯示為連結。You can add custom commands to the AccountsSettingsPane, which appear as links below your supported WebAccountProviders. 自訂命令非常適合用於與使用者關連的簡單工作,例如顯示隱私權原則,或針對遇到問題的使用者啟動支援頁面。Custom commands are great for simple tasks related to user accounts, like displaying a privacy policy or launching a support page for users having trouble.

以下為範例:Here's an example:

private async void BuildPaneAsync(AccountsSettingsPane s, AccountsSettingsPaneCommandsRequestedEventArgs e)
{
    // other code here 
    
    var settingsCmd = new SettingsCommand(
        "settings_privacy", 
        "Privacy policy", 
        async (x) => await Launcher.LaunchUriAsync(new Uri(@"https://privacy.microsoft.com/en-US/"))); 

    e.Commands.Add(settingsCmd); 
    
    // other code here
}

[選擇未列出帳戶的帳戶] 視窗的螢幕擷取畫面,以及隱私權原則的連結。

理論上,您可以使用 settings 命令來做任何事情。Theoretically, you can use settings commands for anything. 不過,我們建議僅將它們使用在直覺、與帳戶相關的案例上,例如上述的案例。However, we suggest limiting their use to intuitive, account-related scenarios like those described above.

另請參閱See also

Windows.Security.Authentication.Web.Core 命名空間Windows.Security.Authentication.Web.Core namespace

Windows.Security.Credentials 命名空間Windows.Security.Credentials namespace

AccountsSettingsPane 類別AccountsSettingsPane class

Web 驗證代理人Web authentication broker

Web 帳戶管理範例Web account management sample

Lunch Scheduler (午餐排程器) appLunch Scheduler app