I had some code scraping ESPN fantasy league data with JSOUP that was working. Unfortunately with the new season the old season data was moved behind an authentication wall and I have been having some issues authenticating with ESPN. I have viewed the login headers/data with chrome dev tools, but am having trouble successfully authenticating. My goal is to get successful cookies from this request to pass on to all successive GET requests.
public static Connection.Response login(String username, String password) throws IOException{
String url = "http://www.espn.com/fantasy/football/";
Connection connection1 = Jsoup.connect(url).userAgent("Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6").method(Connection.Method.GET);
Connection.Response response = connection1.execute();
url = "https://ha.registerdisney.go.com/jgc/v5/client/ESPN-FANTASYLM-PROD/guest/login?langPref=en-US";
Connection.Response connection2 = Jsoup.connect(url)
.userAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36")
.data("loginValue", username, "password", password)
.header("host", "ha.registerdisney.go.com")
.header("correlation-id", "dfc537c2-8fe0-40e2-8d72-04617d11a078")
.header("authorization", "APIKEY 3gC3ZEgR+6YLQc8/oNygcm37bXong2jhstiAui9FOMN8hng3MWMQklxUrRG3rUMDLOS0+2wMeZ59gdT1xoL1u25NUg==")
.header("content-type", "application/json")
.header("conversation-id", "45dde0a2-3097-4821-910c-e074caac97b1")
.header("Origin", "https://cdn.registerdisney.go.com")
.header("expires", "-1")
.cookies(response.cookies())
.method(Connection.Method.POST)
.execute();
I am using a get request on the url first and passing those cookies to seem like a human, and belive that I have all necessary values in the request, but just cannot get it working. Any reccommendations are appreciated!