Using just a password-based authentication, it's easy to authenticate in CSOM:
context.Credentials = new SharePointOnlineCredentials(username, password);
But how to authenticate when Multi-factor authentication is in place (http://technet.microsoft.com/en-us/library/dn249471.aspx)?