2016-12-15 41 views
0

我正在使用WSO2 API管理器1.10.0,並將WSO2 Identity Server 5.1.0配置爲密鑰管理器,並將MySQL社區服務器5.6配置爲使用數據庫。當我嘗試刷新使用授權代碼授予類型獲得的令牌(refresh_token授予類型)時,我收到了400錯誤請求錯誤(invalid_grant - 提供的授權授予無效),我無法獲取新的令牌。然後我嘗試了client_credentials和密碼授權類型,對於那些我可以刷新令牌。使用授權碼流獲取具有有效刷新令牌的新令牌時出錯

我檢查了Identity Server日誌,發現當Identity Server嘗試檢索最新的令牌(下面的日誌)時出現錯誤。

TID: [-1234] [] [2016-12-15 12:40:00,470] DEBUG {org.wso2.carbon.identity.oauth2.OAuth2Service} - Access Token request received for Client ID OQU0_FyRQcdvTFbygziFw67ASHwa, User ID null, Scope : [openid, profile] and Grant Type : refresh_token 
TID: [-1234] [] [2016-12-15 12:40:00,470] DEBUG {org.wso2.carbon.identity.oauth2.token.handlers.clientauth.AbstractClientAuthHandler} - Can authenticate with client ID and Secret. Client ID: OQU0_FyRQcdvTFbygziFw67ASHwa 
TID: [-1234] [] [2016-12-15 12:40:00,470] DEBUG {org.wso2.carbon.identity.oauth2.token.handlers.clientauth.AbstractClientAuthHandler} - Grant type : refresh_token Strict client validation set to : null 
TID: [-1234] [] [2016-12-15 12:40:00,470] DEBUG {org.wso2.carbon.identity.oauth2.util.OAuth2Util} - Client credentials were available in the cache for client id : OQU0_FyRQcdvTFbygziFw67ASHwa 
TID: [-1234] [] [2016-12-15 12:40:00,470] DEBUG {org.wso2.carbon.identity.oauth2.util.OAuth2Util} - Successfully authenticated the client with client id : OQU0_FyRQcdvTFbygziFw67ASHwa 
TID: [-1234] [] [2016-12-15 12:40:00,474] DEBUG {org.wso2.carbon.identity.oauth2.token.handlers.grant.RefreshGrantHandler} - Error while retrieving the latest refresh token 
TID: [-1234] [] [2016-12-15 12:40:00,474] DEBUG {org.wso2.carbon.identity.oauth2.token.AccessTokenIssuer} - Invalid Grant provided by the client Id: OQU0_FyRQcdvTFbygziFw67ASHwa 
TID: [-1234] [] [2016-12-15 12:40:00,474] DEBUG {org.wso2.carbon.identity.oauth2.token.AccessTokenIssuer} - OAuth-Error-Code=invalid_grant client-id=OQU0_FyRQcdvTFbygziFw67ASHwa grant-type=refresh_token scope=openid profile 
TID: [-1234] [] [2016-12-15 12:40:06,492] DEBUG {org.wso2.carbon.core.deployment.CarbonDeploymentSchedulerTask} - Running deployment synchronizer update... tenant : carbon.super 
TID: [-1234] [] [2016-12-15 12:40:06,588] DEBUG {org.wso2.carbon.core.deployment.CarbonDeploymentSchedulerTask} - Running deployment synchronizer commit... tenant : carbon.super 

我調試的source code,我認爲這個問題可能與下面的SQL查詢,特別是與USER_DOMAIN = NULL子句。

SELECT ACCESS_TOKEN, REFRESH_TOKEN, TIME_CREATED, REFRESH_TOKEN_TIME_CREATED, VALIDITY_PERIOD, REFRESH_TOKEN_VALIDITY_PERIOD, TOKEN_STATE, USER_TYPE, TOKEN_ID, SUBJECT_IDENTIFIER FROM IDN_OAUTH2_ACCESS_TOKEN WHERE CONSUMER_KEY_ID = (SELECT ID FROM IDN_OAUTH_CONSUMER_APPS WHERE CONSUMER_KEY = 'OQU0_FyRQcdvTFbygziFw67ASHwa') AND AUTHZ_USER='michael.pinheiro' AND TENANT_ID=-1234 AND USER_DOMAIN=null AND TOKEN_SCOPE_HASH='369db21a386ae433e65c0ff34d35708d' ORDER BY TIME_CREATED DESC LIMIT 1 

我還注意到,使用授權碼交付式,在表所創建的接入令牌IDN_OAUTH2_ACCESS_TOKEN具有用戶域列設置然而爲NULL使用密碼或client_credentials授予鍵入值時,當是「主」。

它可能是一個錯誤,或者我錯過了任何參數,當創建新的訪問令牌時,會以某種方式將用戶域設置爲PRIMARY?

我寫下來的一切,我執行重現該問題的步驟:

第1步: 我被重定向到https://identity-dev.domain.pt/oauth2/authorize?response_type=code&client_id=OQU0_FyRQcdvTFbygziFw67ASHwa&scope=openid輪廓& REDIRECT_URI獲取授權碼= http://localhost:8100

步驟2: 使用上一步中收到的代碼,我通過執行以下命令獲取訪問令牌(和刷新令牌):

捲曲-X POST -H 「內容類型:應用程序/ x WWW的形式進行了urlencoded」 -d「grant_type = authorization_code & CLIENT_ID = OQU0_FyRQcdvTFbygziFw67ASHwa & client_secret = 3kC6Uf9f8Lr8HVl2n03dhQc57Jsa &範圍= OpenID的輪廓&代碼= fd2f827afefba0ab0b17f9d701ad1488 & REDIRECT_URI = http://localhost:8100 '‘https://identity-dev.domain.pt/oauth2/token

步驟3: 利用接收到刷新令牌在上一步,我執行以下請求,以獲得新的令牌,但是我收到了400錯誤的請求,因爲這個崗位解釋。

捲曲-X POST -H 「授權:基本T1FVMF9GeVJRY2R2VEZieWd6aUZ3NjdBU0h3YToza0M2VWY5ZjhMcjhIVmwybjAzZGhRYzU3SnNh」 -H 「內容類型:應用程序/ x WWW的形式進行了urlencoded」 -H 「接受:應用/ JSON」 -d「grant_type = refresh_token &範圍= openid profile & refresh_token = 7a7da99d70d48e10ac82e3681c63b0a1'「https://identity-dev.domain.pt/oauth2/token

歡迎任何幫助!

回答

0

此問題已在[1]中報告,並在更高版本中得到修復。查看jira鏈接中的修復。您可以嘗試使用IS 5.2與APIM 2.0.0。0配置爲密鑰管理器

[1] https://wso2.org/jira/browse/IDENTITY-4322