mic*_*hal 5 php guzzle keycloak
您好,我在发送电子邮件重置密码时遇到问题。我使用的是Keycloak 4.8。在文档中我发现:
向用户发送更新帐户电子邮件 电子邮件中包含一个链接,用户可以单击该链接来执行一组所需的操作。
PUT /{realm}/users/{id}/execute-actions-email
Run Code Online (Sandbox Code Playgroud)
和必需的参数:
id、realm和actions。
我使用 Guzzle 编写方法:
$client = new \GuzzleHttp\Client();
$response = $client->request('put', 'https://myserwerkeycloak.com/auth/admin/realms/testrealm/users/a98e...00d1/execute-actions-email', [
'headers' => [
'User-Agent' => $_SERVER['HTTP_USER_AGENT'],
'Content-Type' => 'application/json',
'Accept' => 'application/json'
],
'form_params' => [
json_encode([
'actions' => ['UPDATE_PASSWORD'],
])
]
]);
Run Code Online (Sandbox Code Playgroud)
$response返回 401 未经授权
所以我添加了令牌:
'Authorization' => 'Bearer ' . $access_token,
Run Code Online (Sandbox Code Playgroud)
不,我有错误 500:
local.ERROR:服务器错误:
PUT https://myserwerkeycloak.pl/auth/admin/realms/testrealm/users/a98e...00d1/execute-actions-email导致500 Internal Server Error响应 {“异常”:“[对象](GuzzleHttp\Exception\ServerException(代码:500):服务器错误:PUT https://myserwerkeycloak.pl/auth/admin/realms/testrealm/users/a98e...00d1/execute-actions-email导致500 Internal Server ErrorC:\xampp\htdocs\project\project 响应\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php:113)
但是当我不会生成时,$access_token我需要使用电子邮件和密码,所以这不是很好的解决方案,因为我单击“忘记密码,发送电子邮件...”
未经授权如何使用execute-actions-email?