@@ -129,25 +129,29 @@ private async Task GetTokenSilentlyAsync()
129
129
}
130
130
131
131
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 ( ) ;
146
137
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 ) ;
148
143
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
+ }
150
155
151
- }
152
156
}
153
157
}
0 commit comments