使用以下Python代码测试Oauth2的oauth2 / userprofile查询:
verify='/home/claudef/tmp/oauth2/oauth/wso2.pem'
url = "https://extbasicpacman05.podc.sl.edst.red.com:9443/oauth2/userinfo?schema=openid"
headers = { 'Authorization' : "Bearer " + access_token }
r = requests.get(url, headers=headers, verify=verify)
我从WSO2标识服务器收到以下错误消息:
error":"insufficient_scope","error_description":"Access token does not have the openid scope"
检查从持有者令牌发射返回的数据,我看到scope = profile的默认值,它与userinfo查询中的默认值不匹配,可能使用值scope = openid .
u'token_type': u'bearer', u'scope': u'profile', u'access_token': u'7ae4542fe322d3aba67bf0625039d5f6', u'expires_in': 73, u'refresh_token': u'92d915a25d8bef6ca7ec7b70664c5cbf'}
使用cURL命令时也会显示相同的错误 .
请给我一些指导如何修复此问题以从WSO2服务器读取userinfo数据 .
1 回答
我已经解决了这个问题 . 需要将范围值放在授权代码的初始请求中,从Oauth2身份验证序列的开头添加参数 . 添加“scope = openid”参数,如下所示,修复了该问题