问题
NFL has an api service. link: https://api.nfl.com/docs/getting-started/index.html
For making api calls we need an Oauth2 access token.
To generate it we need to hit /oauth/token endpoint with parameters client_id and client_secret in body.Now I cannot find any documentation on how to generate the client_id and client_secret.
Another way I found was to create a new user which just requires you to pass necessary parameters like username,password,etc and in turn gives a new access token.But doing this way also gives a unauthorized 401.
So I am doing it wrong.If someone has used this api in past , please do share how you did it.I also found another question here on the same topic link : How would I create an access token for the NFL Shield API? but it does not have any answer.I am sharing the links to two docs related to authentication.
https://api.nfl.com/docs/identity/oauth2/index.html
https://api.nfl.com/docs/identity/register/index.html
回答1:
In case anyone is still looking for a stable NFL api, I have used the predecessor of the this repo and it worked great. It uses an the NFL.com gamecenter liveupdate json file:
http://www.nfl.com/liveupdate/game-center/%s/%s_gtd.json
Notes: %s is game id (available in Scorestrip below).
Example: 2019122909 is for the Chicago Bears last game VS MIN LINK. It is the game's Date YYYYMMDD and the game's index (I believe this is in alphabetical order based on home team's code) if you are trying to code manually.
Another option for just games is the NFL Scorestrip endpoint (used by above-reference repo):
Sample: http://www.nfl.com/ajax/scorestrip?season=2019&seasonType=REG&week=16 Notes: SeasonTypes (PRE, REG, POST), Superbowl is week 22. Live parameters for Current Week available from nfl.com feed.
Mad props to Andrew Gallant (BurntSushi on Github) for all of this. With the NFL's profits, they should really just provide free api access to anyone who wants it, but as we all know they are a bit on the control-freak side.
来源:https://stackoverflow.com/questions/53147256/generating-access-token-for-nfl-api