Further refactoring of [rest] and [oauth].