断言解码的刷新令牌中存在数组键。
作者: mrtus创建于 2026年2月20日更新于 2026年3月15日
当用户使用 `RefreshTokenGrant` 时,它们似乎使用 `AuthCodeGrant` 的令牌值作为 `refresh_token` 值。这当然是不正确的,但框架无法正确处理这种情况。 由于两个令牌都使用相同的加密密钥,解密过程不会出现任何错误。 但是,在将令牌转换为 JSON 后,数组缺少了 `refresh_token_id` 这一数组键。 这导致 `if ($this->refreshTokenRepository->isRefreshTokenRevoked($refreshTokenData['refresh_token_id']) === true) {` 会抛出 `TypeError` 异常,因为向 `string $tokenId` 方法签名传递了一个 `null` 参数。 **建议** 在使用数组键之前验证它们是否存在,否则请抛出 `throw OAuthServerException::invalidRequest('refresh_token')` 异常。
内容来源: thephpleague/oauth2-server