User private method handle401() to avoid duplicated code.