Python中的FIWARE OAuth2身份验证

时间:2015-03-20 10:27:47

标签: python oauth fiware

我正在尝试使用FIWARE对用户进行身份验证。

它返回404.因此在步骤1本身失败。什么是访问令牌网址?任何其他要检查的指针

我尝试过'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)

1 个答案:

答案 0 :(得分:1)

正确的终点是" / oauth2 / token"。

也许您应该使用POST方法而不是GET。

有关详细信息,请参阅https://github.com/ging/fi-ware-idm/wiki/Using-the-FI-LAB-instance