private void WebBrowser_Navigated(object sender, WebBrowserNavigatedEventArgs e) { if (_credentialsSet) { return; } if (!WebBrowser.Url.AbsoluteUri.Contains("code")) { return; } var authToken = _sms.ExtractAuthToken(WebBrowser.Url.AbsoluteUri); var oauthResponse = _sms.GetRequestTokens(authToken); _sms.SaveOauthResponse(oauthResponse); //Close(); Hide(); _credentialsSet = true; if (CredentialsSet != null) { CredentialsSet(this, EventArgs.Empty); } }