Major refactoring to provide OAuth support for all APIs.