【发布时间】:2015-04-13 17:51:27
【问题描述】:
我正在尝试使用 FIWARE 对用户进行身份验证。
它返回 404。因此在步骤 1 本身失败。什么是访问令牌 url?任何其他要检查的指针
我尝试了 'oauth/access_token', 'oauth/token' 'oauth2/token' 'oauth2/access_token' 的变体。它们似乎都不起作用。
我的代码如下:
import oauth2 as oauth
# OAuth secret into your project's settings.
consumer = oauth2.Consumer(settings.FIWARE_CLIENT_ID,settings.FIWARE_CLIENT_SECRET)
client = oauth2.Client(consumer)
access_token_url = 'https://account.lab.fiware.org/oauth2/access_token'
# This is the slightly different URL used to authenticate/authorize.
authenticate_url = 'https://account.lab.fiware.org/oauth2/authorize'
def fiware_login(request):
# Step 1. Get a request token from FIWARE.
resp, content = client.request(access_token_url, "GET")
print resp
if resp['status'] != '200':
print content
raise Exception("Invalid response from FIWARE.")
# Step 2. Redirect the user to the authentication URL.
url = "%s?access_token=%s" % (authenticate_url,
resp['access_token'])
return HttpResponseRedirect(url)
【问题讨论】: