instrument code around invalid_credentials