yahoo-fantasy-sports-api icon indicating copy to clipboard operation
yahoo-fantasy-sports-api copied to clipboard

Way to retry request after refreshing token with new 4.0.0 token refresh feature?

Open Liam-OShea opened this issue 3 years ago • 1 comments

Sorry for all the issues! I am enjoying using your app.

I noticed when playing with the new token refresh feature in 4.0.0 that when the token is expired, a new token is requested from Yahoo and supplied to the callback function, but the original request to the API is not remade with the new token.

Is there a way configure it so that the original request is remade upon a successful refresh of the access token?

Liam-OShea avatar Nov 02 '20 14:11 Liam-OShea

Hey @LudicrousLiam, sorry I'm not getting any emails from Github.

I had this built in and then removed it because of issues where users might not specify some of the stuff needed...

If you look at the old fantasy sandbox / docs source code that I had before I built the new version using Next, I have this workflow outlined here: https://github.com/whatadewitt/yahoofantasysandbox/blob/master/routes/index.js#L63

This is a bit convoluted as this lives inside of a catchall route so it can execute any request -- but I think it's what you're looking for.

Basically, I'm using a callback function and you can see on line 70 that if it errors I am refreshing the token and then re-submitting the request. This same workflow MIGHT actually live somewhere in the history of the new sandbox / docs site https://github.com/whatadewitt/fantasy-docs-next/blob/master/pages/api/yahoo/%5B%5B...slug%5D%5D.js as well, but I don't have time to search through it right now.

Again, sorry for the delayed response! Hope I am not too late!

whatadewitt avatar Jan 13 '21 13:01 whatadewitt