简体   繁体   English

WSO2身份和Oauth2-Userinfo引发错误:范围不足

[英]WSO2 Identity and Oauth2 - Userinfo throws Error: Insufficient Scope

Testing the oauth2/userprofile query for Oauth2 with the following Python code: 使用以下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)

I get the following error message from the WSO2 Identity server: 我从WSO2身份服务器收到以下错误消息:

error":"insufficient_scope","error_description":"Access token does not have the openid scope"

Checking the data that returns from the bearer token emission, I see a default value of scope=profile, which does not match the default in the userinfo query, what likely uses the value scope=openid. 检查从承载令牌发射返回的数据,我看到了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'}

The same error also shows up when using a cURL command. 使用cURL命令时也会出现相同的错误。

Please give me some guidance how fix this issue to read userinfo data from the WSO2 server. 请给我一些指导,如何解决此问题以从WSO2服务器读取userinfo数据。

I've isolated the issue. 我已经隔离了问题。 It is required to place the scope value at the initial request for an authorization code, adding the argument right from the begin of the Oauth2 authentication sequence. 需要将范围值放在对授权码的初始请求中,并在Oauth2身份验证序列的开头添加参数。 Adding the "scope=openid" argument, as shown below, fixed the issue 添加“ 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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM