[3.7] Fix api token endpoint response code issue

Fix status code returned by the response when API token endpoint is not attacked using a secure request