'iat' =>
$currentTimestamp - 1, // make the token expired
'nbf' => 1529436192,
'exp' => 1529439792,
'sub' => '7261d26c3e36451095afa7c05f8732b5',
'scopes' =>
['write'
],
];
$expiredToken = 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjBkZmFhOTJkMWNkYTJiZmUyNGMwOGU4MmNhZmExMDY4N2I2ZWEzZTI0MjE4NjcxMmM0YjI3NTA4Y2NjNWQ0MzI3MWQxODYzODA1NDYwYzQ0In0.'
.
(new JoseEncoder())->
base64UrlEncode(json_encode($fakeClaims, \JSON_THROW_ON_ERROR
)) . '.DBYbAWNpwxGL6QngLidboGbr2nmlAwjYcJIqN02sRnZNNFexy9V6uyQQ-8cJ00anwxKhqBovTzHxtXBMhZ47Ix72hxNWLjauKxQlsHAbgIKBDRbJO7QxgOU8gUnSQiXzRzKoX6XBOSHXFSUJ239lF4wai7621aCNFyEvlwf1JZVILsLjVkyIBhvuuwyIPbpEETui19BBaJ0eQZtjXtpzjsWNq1ibUCQvurLACnNxmXIj8xkSNenoX5B4p3R1gbDFuxaNHkGgsrQTwkDtmZxqCb3_0AgFL3XX0mpO5xsIJAI_hLHDPvv5m0lTQgMRrlgNdfE7ecI4GLHMkDmjWoNx_A';
$request =
$request->
withHeader('authorization',
$expiredToken);
$request =
$request->
withAttribute(PlatformRequest::ATTRIBUTE_OAUTH_USER_ID,
$admin->
getUserId());
$userRepository =
$this->
getContainer()->
get('user.repository'
);
// Change user password
$userRepository->
update([[ 'id' =>
$admin->
getUserId(),
'password' => Uuid::
randomHex(),
]], Context::
createDefaultContext());