Move OAuth logic out of views