public function authorizeBrowser(KernelBrowser
$browser): void
{ $authPayload =
[ 'grant_type' => 'password',
'client_id' => 'administration',
'username' =>
$this->name,
'password' =>
$this->password,
];
$browser->
request('POST', '/api/oauth/token',
$authPayload);
$data =
json_decode((string) $browser->
getResponse()->
getContent(), true, 512, \JSON_THROW_ON_ERROR
);
if (!\
array_key_exists('access_token',
$data)) { throw new \
RuntimeException( 'No token returned from API: ' .
($data['errors'
][0
]['detail'
] ?? 'unknown error' .
print_r($data, true
)) );
} if (!\
array_key_exists('refresh_token',
$data)) { throw new \
RuntimeException( 'No refresh_token returned from API: ' .
($data['errors'
][0
]['detail'
] ?? 'unknown error'
) );
}