为什么即使我在 Foursquare API 中使用我的客户端 ID 和客户端密码,我也会收到此需要身份验证的错误?
Why am I getting this Authentication required error even though I am using my client id and client secret for the Foursquare API?
我回到 Python 并想使用 pyfoursquare 包来访问 Foursquare API。我正在尝试使用 API class 中的 venues 方法获取有关场地的信息。我主要是想查明场地页面是否经过 Foursquare 验证。当我提供我的客户 ID、客户密码和地点 ID 时,我不断收到一个错误,指出 "Authentication required",这没有意义,因为我正在提供该信息。任何帮助都会很棒。谢谢你。
import pyfoursquare as foursquare
client_id = ""
client_secret = ""
callback = ""
auth = foursquare.OAuthHandler(client_id, client_secret, callback)
api = foursquare.API(auth)
result = api.venues("4e011a3e62843b639cfa9449")
print result[0].name
如果您想查看错误消息,请告诉我。再次感谢。
我认为您跳过了获取 OAuth2 访问令牌的步骤,因此您未通过技术验证。
查看以下说明,在 "How to Use It" 下:
https://github.com/marcelcaraciolo/foursquare
可能对您有用的行是:
#First Redirect the user who wish to authenticate to.
#It will be create the authorization url for your app
auth_url = auth.get_authorization_url()
print 'Please authorize: ' + auth_url
#If the user accepts, it will be redirected back
#to your registered REDIRECT_URI.
#It will give you a code as
#https://YOUR_REGISTERED_REDIRECT_URI/?code=CODE
code = raw_input('The code: ').strip()
#Now your server will make a request for
#the access token. You can save this
#for future access for your app for this user
access_token = auth.get_access_token(code)
print 'Your access token is ' + access_token
我回到 Python 并想使用 pyfoursquare 包来访问 Foursquare API。我正在尝试使用 API class 中的 venues 方法获取有关场地的信息。我主要是想查明场地页面是否经过 Foursquare 验证。当我提供我的客户 ID、客户密码和地点 ID 时,我不断收到一个错误,指出 "Authentication required",这没有意义,因为我正在提供该信息。任何帮助都会很棒。谢谢你。
import pyfoursquare as foursquare
client_id = ""
client_secret = ""
callback = ""
auth = foursquare.OAuthHandler(client_id, client_secret, callback)
api = foursquare.API(auth)
result = api.venues("4e011a3e62843b639cfa9449")
print result[0].name
如果您想查看错误消息,请告诉我。再次感谢。
我认为您跳过了获取 OAuth2 访问令牌的步骤,因此您未通过技术验证。
查看以下说明,在 "How to Use It" 下:
https://github.com/marcelcaraciolo/foursquare
可能对您有用的行是:
#First Redirect the user who wish to authenticate to.
#It will be create the authorization url for your app
auth_url = auth.get_authorization_url()
print 'Please authorize: ' + auth_url
#If the user accepts, it will be redirected back
#to your registered REDIRECT_URI.
#It will give you a code as
#https://YOUR_REGISTERED_REDIRECT_URI/?code=CODE
code = raw_input('The code: ').strip()
#Now your server will make a request for
#the access token. You can save this
#for future access for your app for this user
access_token = auth.get_access_token(code)
print 'Your access token is ' + access_token