[AuthComponent]How to custom handler when user need authorization

Hi guys

I’m developing rest api; Now client will redirect to sign page if client request a api that need to be authorized.
How to custom handler? I just want give a json response that told client go to sign in and record some logs.