Unable to use espn_s2 cookie to pull draft_recap with leagueHistory=TRUE
Tried to use the espn_s2 cookie value in the ... argument of draft_recap but got 404 error and was unable to get the function to query the data. How does espn_s2 get passed to the functions?
library(fflr)
fflr::ffl_id(leagueId = '123456')
#> Temporarily set `fflr.leagueId` option to 123456
#> [1] "123456"
espn_s2 = "AECLabcdefghijklmnopqrstuvwxyz"
fflr::draft_recap(leagueHistory = TRUE, cookie = espn_s2)
#> Error: ESPN Fantasy API request failed [404]
#> Not Found (No League History?)
The leagueHistory stuff is unfortunately all kinds of messed up. This is something ESPN changed and I'm not sure what I can do to fix it.
See for yourself by navigating to this URL (with your leagueId) in a browser signed into ESPN
https://lm-api-reads.fantasy.espn.com/apis/v3/games/ffl/leagueHistory/42654852?view=mDraftDetail&view=mTeam
And then doing the same thing in an Incognito/Private browser gives the 404 error.
{"messages":["Not Found"],"details":[{"message":"Not Found","shortMessage":"Not Found","resolution":null,"type":"GENERAL_NOT_FOUND","metaData":null}]}
I tested using espn_s2 just the way you did and it worked for some endpoints, so I figured I would implement it now. But on the mDraftDetail view I see like a dozen different cookies EPSN is using to authenticate.
I'll do some more testing soon and post any updated here.
One potential solution would be to re-write draft_recap() etc to optionally accept JSON from a file users can save manually from their web browser (instead of requesting and parsing from the API)
Actually... that's weird.
If you navigate to that URL in your browser
https://lm-api-reads.fantasy.espn.com/apis/v3/games/ffl/leagueHistory/42654852?view=mDraftDetail&view=mTeam
And copy espn_s2 from there and then pass it to draft_racap() it works!? It must be a different cookie for that request and the cookie that loads from the home page.