簡體   English   中英

WSO2身份和Oauth2-Userinfo引發錯誤:范圍不足

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

使用以下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數據。

我已經隔離了問題。 需要將范圍值放在對授權碼的初始請求中,並在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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM