Python 调用UnderArmour api时出现开发人员非活动错误
尝试在UnderArmour连接的健身api中发布到时收到403“Developer Inactive”错误。正在使用的客户端id处于活动状态。调用中使用的url为: 这是在获得授权代码后使用python调用的一个片段:Python 调用UnderArmour api时出现开发人员非活动错误,python,api,oauth2,mapmyfitness,underarmour,Python,Api,Oauth2,Mapmyfitness,Underarmour,尝试在UnderArmour连接的健身api中发布到时收到403“Developer Inactive”错误。正在使用的客户端id处于活动状态。调用中使用的url为: 这是在获得授权代码后使用python调用的一个片段: import requests access_token_url = 'https://api.ua.com/v7.1/oauth2/access_token/' access_token_data = {'grant_type': 'authorization_code'
import requests
access_token_url = 'https://api.ua.com/v7.1/oauth2/access_token/'
access_token_data = {'grant_type': 'authorization_code',
'client_id': CLIENT_ID,
'client_secret': CLIENT_SECRET,
'code': authorize_code}
response = requests.post(url=access_token_url, data=access_token_data)
In [24]: response
Out[24]: <Response [403]>
In [25]: response.content
Out[25]: '<h1>Developer Inactive</h1>'
导入请求
访问\u令牌\u url=https://api.ua.com/v7.1/oauth2/access_token/'
access_token_data={'grant_type':'authorization_code',
“客户id”:客户id,
“客户机密”:客户机密,
“代码”:授权\u代码}
response=requests.post(url=access\u-token\u-url,data=access\u-token\u-data)
在[24]中:应答
出[24]:
在[25]中:response.content
Out[25]:“开发人员不活动”
其中CLIENT_ID和CLIENT_SECRET是我在开发人员门户上的注册值。对api.ua.com的所有调用都必须包含“api密钥”头值,否则,将出现403 developer Inactive错误 此代码段显示了如何在python中执行此操作:
import requests
access_token_url = 'https://api.ua.com/v7.1/oauth2/access_token/'
access_token_data = {'grant_type': 'authorization_code',
'client_id': CLIENT_ID,
'client_secret': CLIENT_SECRET,
'code': authorize_code}
headers = {'api-key': CLIENT_ID}
response = requests.post(url=access_token_url, data=access_token_data, headers=headers)
In [30]: response
Out[30]: <Response [200]>
In [31]: response.content
Out[31]: '{"user_id": "<user_id>", "access_token": "<access token>", "expires_in": 2591999, "token_type": "Bearer", "scope": "read", "user_href": "/v7.1/user/<user id>/", "refresh_token": "<refresh token>"}'
导入请求
访问\u令牌\u url=https://api.ua.com/v7.1/oauth2/access_token/'
access_token_data={'grant_type':'authorization_code',
“客户id”:客户id,
“客户机密”:客户机密,
“代码”:授权\u代码}
headers={'api-key':客户端\ ID}
response=requests.post(url=access\u-token\u-url,data=access\u-token\u-data,headers=headers)
在[30]中:应答
出[30]:
在[31]中:response.content
Out[31]:“{”user_id:“,”access_token:“,”expires_in:”2591999,“token_type:”Bearer“,”scope:”read“,”user_href:“/v7.1/user/”,”refresh_token:“}”
x-api-key和api-key之间有什么区别吗?