generalizing oauth2 handlers