Skip to content

Commit b8b9eb6

Browse files
Merge pull request #3619 from MicrosoftDocs/main638213117883910852sync_temp
For protected CLA branch, push strategy should use PR and merge to target branch method to work around git push error
2 parents 7319bfd + c587e67 commit b8b9eb6

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

uwp/security/code/token-broker/MainPage.xaml.cs

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -129,25 +129,29 @@ private async Task GetTokenSilentlyAsync()
129129
}
130130

131131

132-
private async void SignOutButton_Click(object sender, RoutedEventArgs e)
133-
{
134-
var msaProvider = await WebAuthenticationCoreManager.FindAccountProviderAsync(
135-
"https://login.microsoft.com", "consumers");
136-
var request = new WebTokenRequest(msaProvider, "consumers");
137-
var result = await WebAuthenticationCoreManager.GetTokenSilentlyAsync(request);
138-
if (result.ResponseStatus == WebTokenRequestStatus.UserInteractionRequired)
139-
{
140-
// Unable to get a token silently - you'll need to show the UI
141-
}
142-
else if (result.ResponseStatus == WebTokenRequestStatus.Success)
143-
{
144-
// Success, use your token
145-
}
132+
private async void SignOutButton_Click(object sender, RoutedEventArgs e)
133+
{
134+
// Get the stored provider ID and user ID
135+
string providerId = ApplicationData.Current.RoamingSettings.Values["CurrentUserProviderId"]?.ToString();
136+
string accountId = ApplicationData.Current.RoamingSettings.Values["CurrentUserId"]?.ToString();
146137

147-
string id = ""; // ID obtained from calling https://apis.live.net/v5.0/me?access_token=" + token
138+
if (providerId != null && accountId != null)
139+
{
140+
// Find the account provider and account based on the stored IDs
141+
WebAccountProvider provider = await WebAuthenticationCoreManager.FindAccountProviderAsync(providerId);
142+
WebAccount account = await WebAuthenticationCoreManager.FindAccountAsync(provider, accountId);
148143

149-
var webAccount = await WebAuthenticationCoreManager.FindAccountAsync(msaProvider, id);
144+
// Remove the stored account information
145+
ApplicationData.Current.RoamingSettings.Values["CurrentUserProviderId"] = null;
146+
ApplicationData.Current.RoamingSettings.Values["CurrentUserId"] = null;
147+
148+
// Perform any additional sign-out steps, such as revoking the access token
149+
150+
// Show a sign-out success message or update the UI
151+
152+
// Clear any user-specific data or reset the app state as needed
153+
}
154+
}
150155

151-
}
152156
}
153157
}

0 commit comments

Comments
 (0)