/// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        public void Run(AdWordsUser user)
        {
            // Use a test account for which 2 factor authentication has been enabled.
              string loginEmail = "*****@*****.**";
              string password = "******";

              AdWordsAppConfig config = new AdWordsAppConfig();
              config.Email = loginEmail;
              config.Password = password;
              AuthToken authToken = new AuthToken(config, "adwords");

              try {
            // Try to obtain an authToken.
            string token = authToken.GetToken();
            Console.WriteLine("Retrieved an authToken = {0} for user {1}.", token, loginEmail);
              } catch (AuthTokenException ex) {
            // Since the test account has 2 factor authentication enabled, this block
            // of code will be executed.
            if (ex.ErrorCode == AuthTokenErrorCode.BadAuthentication) {
              if (ex.Info == "InvalidSecondFactor") {
            Console.WriteLine("The user has enabled two factor authentication in this " +
                "account. Have the user generate an application-specific password to make " +
                "calls against the AdWords API. See " +
                "http://adwordsapi.blogspot.com/2011/02/authentication-changes-with-2-step.html" +
                " for more details.");
              } else {
            Console.WriteLine("Invalid credentials.");
              }
            } else {
              throw new System.ApplicationException(String.Format("The server raised an {0} error.",
              ex.ErrorCode));
            }
              }
        }
 public void TestGetTokenThrowsException() {
   try {
     clientLoginInterceptor.RaiseException = true;
     try {
       AuthToken authToken = new AuthToken(config, SERVICE);
       string token = authToken.GetToken();
       Assert.Fail();
     } catch (AuthTokenException ex) {
       Assert.AreEqual(ex.ErrorCode, AuthTokenErrorCode.BadAuthentication);
     }
   } finally {
     clientLoginInterceptor.RaiseException = false;
   }
 }
 public void TestGetToken() {
   AuthToken authToken = new AuthToken(config, SERVICE);
   TestUtils.ValidateRequiredParameters(authToken, new string[] {"Email", "Password"},
       delegate() {
         authToken.GetToken();
       }
   );
   string token = authToken.GetToken();
   Assert.AreEqual(token, ClientLoginRequestInterceptor.AUTH_TOKEN);
 }