
By anoopmohan on
Hi,
I would like to create a centralized user access check (token authentication for iOS / android devices) for all the APIs and return the response as JSON, if the user failed in access check. I tried _custom_access method in routing.yml and created a function in a controller to check the user permission and returned the response as "AccessResult::allowedIf(false)", when the user fails in access check. But, the "AccessResult::allowedIf(false)" returns the HTML page instead of JSON response.
Please advice if there is any best way to implement this feature in Drupal 8 code.
Thanks,