authy-java icon indicating copy to clipboard operation
authy-java copied to clipboard

Details for 401?

Open stephanos opened this issue 13 years ago • 2 comments

Hey,

I'm in the middle of integrating Authy into our system. One thing that irritates me is how I am supposed to distinguish the various error types that hide under a 401.

Currently it could be

  • wrong API keys
  • wrong token (for verification)
  • wrong user

So how am I supposed to know in the code what the root cause was. We wouldn't want to show the user a message straight from your API (e.g. "User doesn't exist."), but show a customized one.

Currently I do this:

if (errMsg.contains("api key"))
    throw new ServiceException("wrong API key");
else if (errMsg.contains("token"))
    throw new TokenException();
else if (errMsg.contains("user"))
    throw new UserException("user not found");
else
    throw new ServiceException(errMsg);

... and this can't be the best way, can it?

stephanos avatar Nov 22 '13 15:11 stephanos

Hi Stephan,

Thats sort of true. But really I wouldn't worry about API Key's or user not found error. On production you should just assume you're sending the right key's and when you call authy with and authy_id that the users exists.

If you are using the wrong keys, nothing will work, and you'll find out right away - you can't just deploy without seeing this issue.

danpal avatar Nov 22 '13 15:11 danpal

You have a point there. Case closed :)

stephanos avatar Nov 22 '13 16:11 stephanos