whatadewitt / yahoo-fantasy-sports-api

NodeJS wrapper for the Yahoo! Fantasy Sports API
https://yahoo-fantasy-node-docs.vercel.app/
MIT License
192 stars 52 forks source link

Y!OAuthAccessToken #54

Closed CallSign-Filter closed 3 years ago

CallSign-Filter commented 4 years ago

This is not an issue with the app so I apologize for posting this here, but I don't know where else to go. I don't know how to get the Y!OAuthAccessToken. I have created and registered by app so I have the consumerKey and the consumerSecret , also I tried getting an account key for my yahoo account (under account security) and got an "app password" (a 16 alpha-numeric character pw) but that is not working. Can any point me in the right direction as to how to get this OAuthAccessToken? Thank you!

whatadewitt commented 4 years ago

While this is not AT ALL a complete "starter kit" you can check out this repo here:

https://github.com/whatadewitt/fantasy-starter-express

That should give you an idea of how things work...

You can also take a look at the code for the sandbox here

https://github.com/whatadewitt/yahoofantasysandbox

LMK if those get you started in the right direction!!

CallSign-Filter commented 4 years ago

Thank you so much! So that did get me started and I was able to get it started. But I am not looking to make a public website. I just want to make a program that I can run and parse out my own team's fantasy data so I can run some calculations and post it as text on my website. Any way I can hard code my login credentials?

We are doing weekly payouts for different things (highest QB score, biggest margin of win, etc.) and I don't want to calculate them every week every year.

whatadewitt commented 4 years ago

Sorry I just saw this.

Unfortunately no. With v2 of the Yahoo! API you need to use a valid access token. What I've done in the past is set up a Redis instance to hold my access/refresh token, and if my requests fail due to an expired access token I use the refresh token to get a new one that is valid and re-try the request.

I would also think you could just setup something that allows you to log in and then just runs the command... not optimal, but I've also done that for some similar scripts I run.

whatadewitt commented 3 years ago

@CallSign-Filter not sure if you're still using this, but I have this resolved and you can make unauthed calls to public endpoints / leagues now.