public static User LoadFromCookie(Windows.Web.Http.HttpCookie cookie) { JsonNode node = new JsonNode(new System.Collections.Generic.Dictionary <string, JsonNode>()); node.getValue_Object()["ts"] = new JsonNode((DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds); node.getValue_Object()["rt"] = new JsonNode(0); node.getValue_Object()["qc"] = new JsonNode(0); return(new User(node, cookie)); }
private void Login_webview_NavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args) { if (args.Uri.AbsoluteUri.Contains("as=")) { Windows.Web.Http.HttpCookie oauth_code = cookieManager.GetCookies(args.Uri).Cast <Windows.Web.Http.HttpCookie>().FirstOrDefault(c => c.Name == "oauth_code"); WTalk.AuthenticationManager.Current.AuthenticateWithCode(oauth_code.Value); Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(MainPage)); return; } }
private User(JsonNode node, Windows.Web.Http.HttpCookie cookie) { this.Timestamp = ApiProvider.UnixTimestamp0.AddSeconds(node.getValue_Object()["ts"].getValue_Number()); this.rt = (long)node.getValue_Object()["rt"].getValue_Number(); this.qc = (long)node.getValue_Object()["qc"].getValue_Number(); bool flag = false; string tmp = ""; string output = ""; foreach (var c in cookie.Value) { if (flag) { if (tmp.Length == 2) { flag = false; output += ((char)Convert.ToInt32(tmp, 16)); tmp = ""; if (c == '%') { flag = true; } else { output += (c); } } else { tmp += (c); } } else { if (c == '%') { flag = true; } else { output += (c); } } } output += ((char)Convert.ToInt32(tmp, 16)); JsonNode cookieContent = new JsonNode(output, true); this.Username = cookieContent.getValue_Object()["n"].getValue_String(); this.UserID = cookieContent.getValue_Object()["id"].getValue_String(); //this.Unknown = (long)cookieContent.getValue_Object()["a"].getValue_Number(); //this.Unknown = (long)cookieContent.getValue_Object()["pp"].getValue_Number(); this.Paid = cookieContent.getValue_Object()["paid"].getValue_Boolean(); }
private void OpenWebView(string RedirectUrl, string strcookie) { try { Uri baseUri = new Uri(RedirectUrl); if (!string.IsNullOrEmpty(strcookie)) { Windows.Web.Http.Filters.HttpBaseProtocolFilter filter = new Windows.Web.Http.Filters.HttpBaseProtocolFilter(); Windows.Web.Http.HttpCookie cookie = new Windows.Web.Http.HttpCookie(baseUri.Host, baseUri.Host, ""); cookie.Value = strcookie; filter.CookieManager.SetCookie(cookie, false); } Windows.Web.Http.HttpRequestMessage httpRequestMessage = new Windows.Web.Http.HttpRequestMessage(Windows.Web.Http.HttpMethod.Get, baseUri); citruswebview.NavigateWithHttpRequestMessage(httpRequestMessage); } catch (Exception exception) { new MessageDialog(exception.Message).ShowAsync(); } }