So i already receive a token from the Json when the login is made without problems, and receive the hash
But when the response from the server is a error, i cannot g
You are mixing a logical error (login failed for some reason) with an application error. If your server sends response with HTTP 200 and a valid json in case of failed login, your application will not call onError at all.
So basically you need to check the (successful) response from the server and decide based on the provided json if the login was successful or not.
onError should be called, for example, in case the server is not reachable or fails to deliver a valid response.
Edit:
I don't know what your TokenResponse
contains but basically the response for a login should be the same, no matter if it was successful or not. You then just check the TokenResponse to find out if the result contains errors or not.
Check this answer as an example: https://stackoverflow.com/a/31159671/180538