![](/img/trans.png)
[英]Generating OAuth Token of Client Credential Grant Type Fails - WSO2 API Manager 1.7.0
[英]WSO2 API Manager Client Credentials renew token
我正在嘗試續訂通過API Manager生成的令牌。
生成令牌的curl語句是:
curl -k -d "grant_type=client_credentials" -H "Authorization: Basic TDQ0SktDZm5DcVVDSVBjdGYwVDIyRWwwUGY4YT
o2d19NQm9xYnBFXzRLNHR0Wkc0NXhxd0NMTDRh , Content-Type: application/x-www-form-urlencoded" https://10.108.106.214:8250/token
回應是
"scope":"am_application_scope default","token_type":"bearer","expires_in":1094,"access_token":"6d1d0f8afbd147d24bcd42bbc5361a1"
根據文檔,它應該生成一個不被生成的retoken。 我錯過了什么?
當我將grant_type作為refresh_token傳遞時。 我收到了無效的授權錯誤。
curl -X POST -H "Authorization: Basic TDQ0SktDZm5DcVVDSVBjdGYwVDIyRWwwUGY4YTo2d19NQm9xYnBFXzRLNHR0Wkc0NXhxd0NMTDRh" -H "Content-Type: application/x-www-form-urlencoded" -d 'grant_type=refresh_token&refresh_token=6d1d0f8afbd147d24bcd42bbc5361a1' 'https://10.108.106.214:8250/token'
我指的是網址https://docs.wso2.com/display/AM191/Token+API#TokenAPI-RenewingaccesstokensRenewing中的文檔
那我錯過了什么?
根據OAuth 2.0授權協議規范,grant_type client_credentials不應發出刷新令牌。
如果訪問令牌請求有效且已獲得授權,則授權服務器會發出訪問令牌,如第5.1節所述。 刷新令牌不應該包括在內。
您必須使用密碼授予類型
要求:
curl -k -d "grant_type=password&username=admin&password=admin" -H "Authorization: Basic bkxidjNPTnYxQ25iTXBRY2E3V3hPajdaMUVZYTpuTUQzX0tKQkhGRmxFUUlXdllmSjdTUFlleThh, Content-Type: application/x-www-form-urlencoded" https://localhost:8243/token
回應:
{"scope":"default","token_type":"bearer","expires_in":3247,"refresh_token":"91729a78a96b58d80d869f3ec2ce8b8","access_token":"ec54b39dd9503c9f65df84b67ea586"}
使用refresh_token
更新訪問令牌
如果我沒有記錯的話,在你收到的回復中。
"scope":"am_application_scope default","token_type":"bearer","expires_in":1094,"access_token":"6d1d0f8afbd147d24bcd42bbc5361a1"
這是新的訪問令牌。
access_token":"6d1d0f8afbd147d24bcd42bbc5361a1"
記下當前令牌,然后再次運行curl命令。 響應應該是不同的標記。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.