я пытаюсь проверить токен доступа, выданный aws cognito на бэкэнд, но я застрял в этом, у меня есть это:
<?php
namespace App\Bridge;
class AwsCognitoClient
{
private $client;
public function __construct(
string $key,
string $secret,
string $poolId,
string $clientId,
string $clientSecret,
string $region,
string $version
) {
$this->region = $region;
$this->poolId = $poolId;
$config = [
'credentials' => [
'key' => $key,
'secret' => $secret,
],
'region' => $region,
'version' => $version,
'app_client_id' => $clientId,
'app_client_secret' => $clientSecret,
'user_pool_id' => $poolId,
];
$aws = new \Aws\Sdk($config);
$this->client = $aws->createCognitoIdentityProvider();
}
public function verifyToken($access_token)
{
try {
$user = $this->client->getUser([
'AccessToken' => $access_token
]);
error_log("USER NULL ALWAYS: " . json_encode($user));
} catch (\Exception $e) {
error_log("ERROR COGNITO: " . $e->getMessage());
}
}
}
но $ this-> client-> getUser всегда быть пустым, и если токен истек, выведите правильное исключение для истекшего, но если токен действителен, не показывайте ничего, только $ user будет пустым; что не так?