-
Notifications
You must be signed in to change notification settings - Fork 224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ESPN Access Denied 2018 Season #278
Comments
That is very strange. The account you are using to access the league, was it part of that season 2018? I can't think of any reason why it would give access denied. |
Was just coming to see if there was anything on this. I also am getting access denied for a number of public leagues for this same reason. Its always just the 2018 season. My only thought is I know ESPN updated their API that year and so I wonder if it has something to do with that? But same as Robbie, other years work fine. Overall though thank you so much for your well-documented code! |
@cwendt94 I was actually not part of the 2018 season, I didn't join until 2019. However, the code is working all the way back to 2013, so I am not sure exactly what the issue is. Sounds like @zanderman12 is experiencing the same issue, so looks to go beyond just my own league. Could it be something with the fact that the API changed that year? Thank you again! |
If you are able to see that season using the ESPN Website you should be able to get that data via their API's. If that is the case, I wonder if there is another token or variable for authentication. |
Hey @robbie11r1 and @cwendt94 I have a theory as to what happened. I think with the updated API in 2018, ESPN also increased their security. My theory is that all leagues were set to private in 2018, at least as far as the API is concerned, with the update. Then commissioners have to manually set the league to public after 2018 for the data to be viewable without credentials. I have now had a few leagues where the access was denied in 2018, 2019, and 2020, but was viewable before 2018 without credentials. I have also had a few people send me their espn_s2 and swid cookies and that fixed the issue. I hope that helps. |
@zanderman12 Hey Alexander, finally getting back around to this two years later... better late than never right! So I am pulling stats from an ESPN league than ran from 2013-2021, and am able to grab stats using this API with my espn_s2 and swid cookies for every year except 2018. This includes 2019, 2020, and 2021, as well as 2013-2017. So in your example, I'm not exactly experiencing the same issue... it is ONLY the year 2018 that is returning. Unfortunately the commissioner no longer has access to change the league visibility... |
So I'm digging into the API a bit and found something odd... I've been doing some manual Get requests and was able to pull my league info for 2018 using what appears to be the "old format": The below is lines 47-50 from the espn_requests.py; the split for API differences is at 2018:
I tried my league with the "older" format, as shown below and it returns proper JSON:
Using the format specified here for 2018 and newer, I am getting an error of "You are not authorized to view this League":
@zanderman12 can you take a look at yours and see if you have the same? Maybe the "fix" is as simple as changing line 47 to <= instead of < |
Okay, so even more digging and testing and I got this package to run for year 2018, but it breaks every other year 😢 I suspect it still has to do with the additional [0] key in the JSON data when pulling that year... For example, in base_league.py lines 48-54 would have to include the [0] key and become:
Not sure if I am off base, but it seems to be what is throwing errors in my testing |
Just submitted PR #514 (should also fix duplicate issue #466 as well). I made the necessary changes to account for 2018 and my tests for years 2013-2021 seem to be working! Also FYI I am the original owner of the account "robbie11r1" who opened this issue... It is an old account of mine that was never used 😄 |
I was looking into this again tonight after seeing the comments on #614 and I revisited the code from my PR #514 from last year. For my 2018 league, the endpoint URL from 2017 and earlier worked, but the API change in 2018 slightly modified the JSON data response. I've got that PR working again with slightly updated code so I'll try and send a new one tomorrow. Just wanted to see if the endpoint from pre-2018 worked for anyone else in 2018 having this same issue. |
Good Morning,
Thank you for your well documented code, this has been great! I am running into one issue that I cannot seem to resolve even after looking through all previous discussions/issues.
I am trying to pull Fantasy Football League data for all seasons 2013-2020 and your "League" class is working great for every season except 2018. I am getting 401 error: "raise ESPNAccessDenied(f"League {league_id} cannot be accessed with swid={cookies.get('espn_s2')} and swid={cookies.get('SWID')}")"
I have verified the season exists on ESPN website, so I am not sure why this specific season is giving this error, and why 2019 and 2020 are having no torouble. It is a private league and I am using SWID and espn_s2 to login to all seasons (except 2018) without an issue.
Any suggestions on how to approach this error?
The text was updated successfully, but these errors were encountered: