edwarddistel / yahoo-fantasy-baseball-reader

Download your fantasy baseball data from the Yahoo API.
76 stars 22 forks source link

NFL 401 error #110

Closed CallSign-Filter closed 1 year ago

CallSign-Filter commented 1 year ago

I used this all last NFL season to parse out the weekly positional scores for my Fantasy Football League's weekly payouts. This year I am getting nothing but 401 errors. I tried my fork from last year, I tried cloning over again and nothing.

PS C:\Users\Brandon\IdeaProjects\OthersProjects\yahoo-fantasy-baseball-reader> npm run league-prefix

> yahoo-fantasy-baseball-reader@1.0.0 league-prefix
> node src/getLeaguePrefix.js

Error with credentials in makeAPIrequest()/refreshAuthorizationToken(): AxiosError: Request failed with status code 401
Error in getLeaguePrefix(): TypeError: Cannot read properties of undefined (reading 'game')
TypeError: Cannot read properties of undefined (reading 'game')
    at Object.getLeaguePrefix (C:\Users\Brandon\IdeaProjects\OthersProjects\yahoo-fantasy-baseball-reader\src\yahooFantasyBaseball.js:260:38)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async getData (C:\Users\Brandon\IdeaProjects\OthersProjects\yahoo-fantasy-baseball-reader\src\getLeaguePrefix.js:11:19)
PS C:\Users\Brandon\IdeaProjects\OthersProjects\yahoo-fantasy-baseball-reader>

I followed all of the steps and have the app registered. Any Ideas?

edwarddistel commented 1 year ago

Most likely an error in setting up your config.json file.

To validate that this is the problem, after line 259 in /src/yahooFantasyBaseball.js add console.log(JSON.stringify(results.response.data)); and run it again, which will likely spit out an error such as:

Error with credentials in makeAPIrequest()/refreshAuthorizationToken(): Error: Request failed with status code 401
{"error":{"lang":"en-US","description":"Please provide valid credentials. OAuth oauth_problem=\"token_rejected\", realm=\"yahooapis.com\""}}

This means your credentials are not set up correctly. I re-ran through my instructions and validated they still work.

I'd make a video showing how exactly it's done except the process involves API passwords.

For baseball the league prefix is 412 for this year, I don't know if it's the same for football.

But the keys are:

Last two you can leave as is.

Hope this helps! Good luck.

CallSign-Filter commented 1 year ago

Okay I must have messed something up because it wasn't generating the credentials.json file over again. So in the fresh one I just downloaded form you (after running the npm install on both versions with the new version of the dependencies) I had it generate a new credentials file that I put into the other one and it worked beautifully.

If you or anyone else if curious, I am using this to parse out the weekly positional scores because in my league we have weekly payouts for different positions each week. Also we pay out for most WR points all year and most RB points all year so I have this app generate the points that I copy into a Google Sheet.

And this NFL season is league prefix 414.

Thank you for your help and the beautiful public service that is this app