我正在尝试连接到FatSecret API。下面是他们为oauth2授权提供的文档的链接:https://platform.fatsecret.com/api/Default.aspx?screen=rapiauth2#using-token-api
我已经完成了第一步和第二步,现在我被困在第三步。我已经设法用“application/json”更新了标题,但我不确定我的调用是否包含我创建的令牌。我收到一个响应代码200,但随后出现一条错误消息: {'error':{'code':21,'message':“检测到无效的IP地址:'51.7.45.86'”}
params = {
'grant_type': 'client_credentials',
'client_id': 'REMOVED',
'client_secret': 'REMOVED',
'scope': 'basic',
'method' : 'foods.search',
'search_expression' : 'toast',
'format' : 'json',
}
api_url = 'https://platform.fatsecret.com/rest/server.api'
response = requests.post(api_url, headers={'content-type' : 'application/json', 'Authorization' : 'Bearer {}'.format(data['access_token'])}, params=params)
应该这样做
相关问题 更多 >
编程相关推荐