【发布时间】:2022-06-11 00:14:47
【问题描述】:
我正在尝试通过我们的 OpenID Connect Keycloak 服务器请求用户信息。当请求访问令牌时,一切都会好起来的。但只要我请求用户信息,我就会收到错误 400。
require __DIR__ . '/vendor/autoload.php';
use Jumbojett\OpenIDConnectClient;
$username = $_REQUEST["Username"];
$password = $_REQUEST["Password"];
$oidc = new OpenIDConnectClient(
'xxx',
'yyy',
'zzz'
);
$oidc->providerConfigParam(array('userinfo_endpoint'=>'xxx/userinfo_endpoint'));
$oidc->addScope('openid');
$oidc->addScope('roles');
$oidc->addScope('profile');
//Add username and password
$oidc->addAuthParam(array('username'=>$username));
$oidc->addAuthParam(array('password'=>$password));
//Perform the auth and return the token (to validate check if the access_token property is there and a valid JWT) :
session_start();
$_SESSION['access_token'] = $oidc->requestResourceOwnerToken(TRUE)->access_token;
// $token = $oidc->requestResourceOwnerToken(TRUE)->access_token;
try {
$name = $oidc->requestUserInfo();
} catch (\Jumbojett\OpenIDConnectClientException $e) {
echo $e;
}
这给出了以下错误代码:
The communication to retrieve user data has failed with status code 400
我知道这与格式或类似问题有关,但我无法弄清楚究竟是什么。
有人可以指点我大致的方向吗?
【问题讨论】:
标签: php keycloak openid-connect http-status-code-400