/**
* Gets the user data when a user is logged in
* @throws BearerErrorResponseException When OAuth authentication failed
* @return array|null The user data when a user is authenticated, or null when there is no user authenticated
*/
public function getUserData()
{
$accessToken = $this->getAccessToken();
if (!$accessToken) {
return null;
}
$this->httpClient->addSubscriber(new BearerAuth($accessToken->getAccessToken()));
try {
$response = $this->httpClient->get($this->authserverUrl . '/api/user.json')->send()->json();
return $response;
} catch (BearerErrorResponseException $ex) {
$this->api->deleteAccessToken($this->context);
$this->api->deleteRefreshToken($this->context);
throw $ex;
}
}