How can I have
/administrator/index.php?option=COM_MYCOMPONENT&controller=MYCONTROLLER&task=MYTASK return a "401 Unauthorized" HTTP error instead of redirecting to the administrator login page?
Joomla Stack Exchange is a question and answer site for Joomla! administrators, users, developers and designers. It only takes a minute to sign up.Sign up to join this community
libraries/src/Application/CMSApplication.php you have two events during the login process that trigger plugins relevant to a login failure or unauthenticated user situation and if you were to create a plugin that was triggered by one of these events you could then return the 401.
In the above code search for either
onUserAuthorisationFailure to see where/when your plugin would be triggered and use the most appropriate one to your needs.