Sync some basic implementation with authbucket/oauth2.