WSO2 API Manager Client Credentials 更新令牌

Sur*_*rya 5 wso2 oauth-2.0 wso2-api-manager

我正在尝试更新通过 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
Run Code Online (Sandbox Code Playgroud)

回应是

"scope":"am_application_scope default","token_type":"bearer","expires_in":1094,"access_token":"6d1d0f8afbd147d24bcd42bbc5361a1"
Run Code Online (Sandbox Code Playgroud)

根据文档,它应该生成一个未生成的重新令牌。我错过了什么?

同样,当我将 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'
Run Code Online (Sandbox Code Playgroud)

我指的是 URL https://docs.wso2.com/display/AM191/Token+API#TokenAPI-RenewingaccesstokensRenewing 中的文档

那么我错过了什么?

Abi*_*san 3

根据OAuth 2.0 授权协议规范,grant_type client_credentials 不应颁发刷新令牌。

4.4.3. 访问令牌响应

如果访问令牌请求有效且已获得授权,则授权服务器将按照第 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
Run Code Online (Sandbox Code Playgroud)

回复 :

{"scope":"default","token_type":"bearer","expires_in":3247,"refresh_token":"91729a78a96b58d80d869f3ec2ce8b8","access_token":"ec54b39dd9503c9f65df84b67ea586"}
Run Code Online (Sandbox Code Playgroud)

使用refresh_token更新访问令牌