WSO2标识和Oauth2-Userinfo引发错误:作用域不足

WSO2标识和Oauth2-Userinfo引发错误:作用域不足,wso2,token,identity,wso2is,Wso2,Token,Identity,Wso2is,使用以下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 " + ac

使用以下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 Identity server收到以下错误消息:

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服务器读取用户信息数据

我已经隔离了这个问题。需要将作用域值放在授权代码的初始请求处,从Oauth2身份验证序列的开始添加参数。添加“scope=openid”参数(如下所示)修复了该问题

<a href="https://extbasicpacman05.podc.sl.edst.red.com:9443/oauth2/authorize?client_id=SXpu7Iaz13YoxM6uT6Lhcu1ixlga&response_type=code&scope=openid&redirect_uri=http://localhost:8080/resources/oauth2Callback&requestedAuthnPolicy=http://www.ibm.com/idaas/authnpolicy/basic">Login via Oauth2</a>