if ($userId =
$request->attributes->
get(PlatformRequest::ATTRIBUTE_OAUTH_USER_ID
)) { $appIntegrationId =
$request->headers->
get(PlatformRequest::HEADER_APP_INTEGRATION_ID
);
// The app integration id header is only to be used by a privileged user
if ($this->
userAppIntegrationHeaderPrivileged($userId,
$appIntegrationId)) { $userId = null;
} else { $appIntegrationId = null;
} return $this->
getAdminApiSource($userId,
$appIntegrationId);
} if (!
$request->attributes->
has(PlatformRequest::ATTRIBUTE_OAUTH_ACCESS_TOKEN_ID
)) { return new SystemSource();
} $clientId =
$request->attributes->
get(PlatformRequest::ATTRIBUTE_OAUTH_CLIENT_ID
);
$keyOrigin = AccessKeyHelper::
getOrigin($clientId);
if ($keyOrigin === 'user'
) { $userId =
$this->
getUserIdByAccessKey($clientId);