为NFL API生成访问令牌 [英] Generating access token for NFL api

查看:93
本文介绍了为NFL API生成访问令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

NFL提供了api服务. 链接: https://api.nfl.com/docs/getting-started/index.html

NFL has an api service. link: https://api.nfl.com/docs/getting-started/index.html

要进行api调用,我们需要一个Oauth2访问令牌.

For making api calls we need an Oauth2 access token.

要生成它,我们需要在正文中使用参数client_id和client_secret击/oauth/token 端点.现在我找不到任何有关如何生成client_id和client_secret的文档.

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.

我发现的另一种方法是创建一个新用户,只需要您传递必要的参数(例如用户名,密码等),然后提供一个新的访问令牌.但是,这样做还会得到未授权的401.

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.

所以我做错了.如果以前有人使用过此api,请分享您的用法.我还在同一主题 link 上找到了另一个问题:如何为NFL Shield API创建访问令牌?,但没有任何答案.我正在共享与身份验证相关的两个文档的链接.

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

推荐答案

如果有人仍在寻找稳定的NFL api,我就使用了

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

注意:%s是游戏ID(在下面的Scorestrip中可用).

Notes: %s is game id (available in Scorestrip below).

示例:2019122909是针对芝加哥熊队的上一场比赛VS MIN LINK .如果您尝试手动进行编码,则为游戏的日期YYYYMMDD和游戏的索引(我相信这是基于主队代码的字母顺序).

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.

仅用于游戏的另一个选项是NFL Scorestrip端点(由参考站上方的仓库使用):

Another option for just games is the NFL Scorestrip endpoint (used by above-reference repo):

示例: http://www.nfl .com/ajax/scorestrip?season = 2019& seasonType = REG& week = 16 注意:SeasonTypes(PRE,REG,POST),超级碗是第22周.当前的实时参数周可从nfl.com提要中获取.

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.

对安德鲁·加兰特( Github上的BurntSushi )的疯狂道具.有了NFL的利润,他们实际上应该只向需要它的任何人提供免费的api访问,但是众所周知,他们有点控制狂.

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.

这篇关于为NFL API生成访问令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆