public async Task <string> GetCodeFromCallBack() { WebBrowser webBrowser = WebBrowserExtension.GetWebBrowser(); string str; do { await Task.Delay(1000); str = webBrowser.Source?.ToString() ?? ""; if (str.Contains("http://localhost/auth_cancle")) { break; } } while (!str.Contains("http://localhost/?code")); if (str.Contains("http://localhost/?code")) { string[] strsplit = str.Split('='); string[] strcode = strsplit[1].Split('&'); return(strcode[0]); } else { return(""); } }
private void WebBrowserClear() { WebBrowser webBrowser = WebBrowserExtension.GetWebBrowser(); var ptr = Marshal.AllocHGlobal(4); Marshal.WriteInt32(ptr, 3); InternetSetOption(IntPtr.Zero, 81, ptr, 4); Marshal.Release(ptr); }