Keycloak发送电子邮件重置密码401未经授权或500内部服务器错误

时间:2019-05-20 13:24:22

标签: php keycloak guzzle

嗨,我在发送电子邮件以重置密码时遇到问题。我使用Keycloak 4.8。在documencation中,我发现:

  

向用户发送更新帐户电子邮件。电子邮件中包含一个链接,用户可以单击该链接来执行一组必需的操作。

PUT /{realm}/users/{id}/execute-actions-email

必填参数: idrealmactions

我使用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'],
            ])
        ]
    ]);

$response返回401未经授权

所以我添加了令牌:

'Authorization' => 'Bearer ' . $access_token,

不,我有错误500:

  

local.ERROR:服务器错误:PUT https://myserwerkeycloak.pl/auth/admin/realms/testrealm/users/a98e...00d1/execute-actions-email   产生了500 Internal Server Error的回复   {“ exception”:“ [object](GuzzleHttp \ Exception \ ServerException(代码:   500):服务器错误:PUT https://myserwerkeycloak.pl/auth/admin/realms/testrealm/users/a98e...00d1/execute-actions-email   在产生了500 Internal Server Error响应   C:\ xampp \ htdocs \ project \ project \ vendor \ guzzlehttp \ guzzle \ src \ Exception \ RequestException.php:113)

但是我不会生成$access_token,我需要使用电子邮件和密码,所以这不是很好的解决方法,因为我单击了“忘记密码,发送电子邮件...”

我如何在未经授权的情况下使用execute-actions-email

0 个答案:

没有答案