Fixes some bugs on getting userid from token, and presenting error, with authorizationFailed