在Foursquare API中搜索用户-缺少凭据错误401

问题描述 投票:0回答:1

请帮助。我正在尝试在Foursquare中搜索特定用户,但由于某种原因,我收到了缺少凭据错误401。

user_id = '484542633' # user ID with most agree counts and complete profile

url = 'https://api.foursquare.com/v2/users/{}?client_id={}&client_secret={}&v={}'.format(user_id, CLIENT_ID, CLIENT_SECRET, VERSION) # define URL

# send GET request
results = requests.get(url).json()
user_data = results['response']['user']

# display features associated with user
user_data.keys()
python api foursquare
1个回答
0
投票

作为文档states,该端点应由用户代表访问:

此端点需要用户验证。

用户调用在每个请求的查询字符串中都需要有效的OAuth访问令牌,而不是客户端ID和密钥(&oauth_token = XXXX)。

有关此身份验证方法以及如何获取访问令牌的更多信息,请参阅身份验证文档。

这意味着v2/users可以由您的应用访问,之后用户(可以是您,使用您自己的Foursquare帐户)通过OAuth登录流程和授予必要的权限。 OAuth并不意味着您的应用以用户身份“登录”,而是说the user已授予您代表他们执行something的权限。

要了解有关OAuth的更多信息,您可以观看此演讲:https://www.youtube.com/watch?v=996OiexHze0

要了解有关Foursquare API的更多信息,请访问其文档站点:https://developer.foursquare.com/docs/api/

© www.soinside.com 2019 - 2024. All rights reserved.