private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { string url = ""; if (webBrowser1.Url != null) { url = webBrowser1.Url.AbsoluteUri; } if (url.ToString().Contains(redirectUri)) { string queryParams = e.Url.Query; if (queryParams.Length > 0) { NameValueCollection qs = HttpUtility.ParseQueryString(queryParams); if (qs["code"] != null) { string authCode = qs["code"]; access = AuthResponse.Exchange(authCode, clientId, clientSecret, redirectUri); this.Close(); } } string[] theCookies = System.IO.Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.Cookies)); foreach (string currentFile in theCookies) { try { System.IO.File.Delete(currentFile); } catch (Exception ex) { } } } }
public Login() { InitializeComponent(); webBrowser1.Navigate(AuthResponse.GetAutenticationURI(clientId, redirectUri, state)); }
public static AuthResponse get(string response) { AuthResponse result = JsonConvert.DeserializeObject <AuthResponse>(response); return(result); }