首页 > 解决方案 > WSO2 Identity Server OAuth2 访问令牌请求重定向到登录页面

问题描述

我正在尝试向https://{identity-server}:9443/oauth2/token. 并且请求被重定向到 Location: https://{identity-server}:9443/carbon/admin/login.jsp。我使用的版本是 IS 5.7.0,并作为集群设置部署在 Kubernetes 上。

标签: wso2wso2is

解决方案


您在请求中缺少授权标头。这就是您被重定向到登录页面的原因。

尝试提供这样的授权标头

Authorization: Basic [Base64encode(Client-ID>:<ClientSecret>)]

最终请求应该与此类似

curl -X POST \
  https://localhost:9443/oauth2/token \
  -H 'Authorization: Basic Zkd2ZlhiQ05VeUFmd2ltQW9HSWYycXZDakdFYTpFb1NOWDdHNFQ2NGZjcVFyZTVIX2NPR01CS2Nh' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'username=admin&password=admin&grant_type=password&scope=bearer'

推荐阅读