Foursquare 身份验证 - 'No handlers could be found for logger "foursquare"'

Foursquare authentication - 'No handlers could be found for logger "foursquare"'

我在 Python 中开始使用 Foursquare API,我不确定为什么我无法进行身份验证。

按照教程,到目前为止我有这段代码:

import foursquare
client = foursquare.Foursquare(client_id=myid, client_secret=mysecret, 
                               redirect_uri='http://fondu.com/oauth/authorize')
auth_uri = client.oauth.auth_url()
access_token = client.oauth.get_token('XX_CODE_RETURNED_IN_REDIRECT_XX')
client.set_access_token(access_token)

client.venues.explore(params={'near': 'New York, NY', 'time' : date})

我在这里创建了一个应用程序:

https://foursquare.com/developers/apps

我正在使用两者:

客户编号

客户端密码

显示在页面中。

然而,当运行这段代码时,我得到:

No handlers could be found for logger "foursquare"
Traceback (most recent call last):
  File "noiseInference.py", line 270, in <module>
    getFoursquareCheckIns(date)
  File "noiseInference.py", line 156, in getFoursquareCheckIns
    access_token = client.oauth.get_token('XX_CODE_RETURNED_IN_REDIRECT_XX')
  File "/Library/Python/2.7/site-packages/foursquare/__init__.py", line 134, in get_token
    response = _request_with_retry(url)
  File "/Library/Python/2.7/site-packages/foursquare/__init__.py", line 707, in _request_with_retry
    return _process_request_with_httplib2(url, headers, data)
  File "/Library/Python/2.7/site-packages/foursquare/__init__.py", line 730, in _process_request_with_httplib2
    return _check_response(data)
  File "/Library/Python/2.7/site-packages/foursquare/__init__.py", line 763, in _check_response
    raise FoursquareException(errmsg)
foursquare.FoursquareException: Response format invalid, missing meta property. data: {u'error': u'invalid_client'}

不确定是什么问题。

处理程序消息只是抱怨您没有为 foursquare 命名空间设置记录器。

您真正的错误是堆栈跟踪末尾的消息:

foursquare.FoursquareException: 
    Response format invalid, missing meta property. data: {u'error': u'invalid_client'}

该消息表明您的客户的凭据不正确。在您尝试使用客户端执行诸如 client.set_access_token 之类的特权操作之前,不会完全检查凭据,因此这里最有可能的罪魁祸首是查看您在构造 Foursquare 客户端对象时为 client_secret 传递的内容.

client_id 可能不是问题,因为您必须通过 URL-OAuth 流程才能获得您使用的 access_token