private async void WebBrowser_Navigating(object sender, NavigatingCancelEventArgs e) { var uri = e.Uri; if (uri.ToString().StartsWith(OidcClient.Options.RedirectUri)) { var code = OidcClient.GetCode(uri.Query); var token = await _oidcClient.GetTokenAsync(code); TokenFile.Write(token); this.Close(); } }