Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions OAuthDesktopApp/OAuthDesktopApp/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,22 @@ private async void button_Click(object sender, RoutedEventArgs e)
var http = new HttpListener();
http.Prefixes.Add(redirectURI);
output("Listening..");
http.Start();


try
{
http.Start();
}
catch (HttpListenerException ex)
{
if (ex.HResult == unchecked((int) 0x80004005))
{
MessageBox.Show("Access denied. Try running the program as an administrator.", "OAuthDesktopApp",
MessageBoxButton.OK, MessageBoxImage.Warning);

return;
}
}

// Creates the OAuth 2.0 authorization request.
string authorizationRequest = string.Format("{0}?response_type=code&scope=openid%20profile&redirect_uri={1}&client_id={2}&state={3}&code_challenge={4}&code_challenge_method={5}",
authorizationEndpoint,
Expand Down