8.5.2. 获取有关 RPT 的信息


令牌内省基本上是一个 OAuth2 令牌内省与端点,您可以从中获取有关 RPT 的信息。

http://${host}:${port}/realms/${realm-name}/protocol/openid-connect/token/introspect

要使用此端点内省 RPT,您可以向服务器发送请求,如下所示:

curl -X POST \
    -H "Authorization: Basic aGVsbG8td29ybGQtYXV0aHotc2VydmljZTpzZWNyZXQ=" \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -d 'token_type_hint=requesting_party_token&token=${RPT}' \
    "http://localhost:8080/realms/hello-world-authz/protocol/openid-connect/token/introspect"
注意

上面的请求使用 HTTP BASIC,并传递客户端的凭据(客户端 ID 和机密),以验证尝试内省令牌的客户端,但您可以使用红帽构建的 Keycloak 支持的任何其他客户端验证方法。

内省端点需要两个参数:

  • token_type_hint

    使用 request_party_token 作为此参数的值,这表示您要内省 RPT。

  • token

    在授权过程中,使用令牌字符串作为此参数的值,由服务器在授权过程中返回。

因此,服务器响应:

{
  "permissions": [
    {
      "resource_id": "90ccc6fc-b296-4cd1-881e-089e1ee15957",
      "resource_name": "Hello World Resource"
    }
  ],
  "exp": 1465314139,
  "nbf": 0,
  "iat": 1465313839,
  "aud": "hello-world-authz-service",
  "active": true
}

如果 RPT 未激活,则返回这个响应:

{
  "active": false
}
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

关于红帽文档

Legal Notice

Theme

© 2026 Red Hat
返回顶部