private WaypointSpartanTokenDocument GetWaypointSpartanToken(WaypointAuthTokenDocument authToken) { HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(String.Format(waypointRegisterUrl, (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds)); request.Accept = "application/json"; request.Headers.Add("Origin", "https://app.halowaypoint.com"); request.Headers.Add("X-343-Authorization-WLID", "v1=" + authToken.access_token); request.CookieContainer = Halo4Api.Cookies; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); WaypointSpartanTokenDocument spartanToken; try { spartanToken = JsonConvert.DeserializeObject <WaypointSpartanTokenDocument>(BetterWebResponse.GetBody(response)); } catch (Exception) { throw new Exception("Could not parse Spartan token."); } Halo4Api.Cookies.Add(response.Cookies); return(spartanToken); }
private string GetSpartanTokenViaMicrosoftAuth(string email, string pass) { string waypointCallbackUrl = PerformWaypointLogin(email, pass); string waypointHomepage = GetWaypointWebAuthTokenAndHomepage(waypointCallbackUrl); // Loads the WebAuth token into the cookie store WaypointAuthTokenDocument waypointAuthToken = GetWaypointAuthToken(waypointHomepage); WaypointSpartanTokenDocument waypointSpartanToken = GetWaypointSpartanToken(waypointAuthToken); return(waypointSpartanToken.SpartanToken); }
private WaypointSpartanTokenDocument GetWaypointSpartanToken(WaypointAuthTokenDocument authToken) { HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(String.Format(waypointRegisterUrl, (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds)); request.Accept = "application/json"; request.Headers.Add("Origin", "https://app.halowaypoint.com"); request.Headers.Add("X-343-Authorization-WLID", "v1=" + authToken.access_token); request.CookieContainer = Halo4Api.Cookies; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); WaypointSpartanTokenDocument spartanToken; try { spartanToken = JsonConvert.DeserializeObject<WaypointSpartanTokenDocument>(BetterWebResponse.GetBody(response)); } catch (Exception) { throw new Exception("Could not parse Spartan token."); } Halo4Api.Cookies.Add(response.Cookies); return spartanToken; }