Oops, should be:
===================
        private static string token = null;
        private static DateTime serviceExpiry = DateTime.MinValue;

        private static AppsService GetService()
        {
            string domain = "xxx.com";

            DateTime now = DateTime.Now;
            if (string.IsNullOrEmpty(token) || now > serviceExpiry)
            {
                //Get new token
                string username = "[email protected]";
                string password = "password"
                token = AppsService.GetNewAuthenticationToken(domain,
username, password);

                //Set token expiry date
                int expiryhours = 24;
                serviceExpiry = now.AddHours(expiryhours);
            }
            return new AppsService(domain, token);
        }

        public static void CreateEmailAccount(string userName, string
firstName, string lastName, string password)
        {
            try
            {
                AppsService service = GetService();
                service.CreateUser(userName, firstName, lastName,
password);
            }
            catch (Exception ex)
            {
                //...
            }
        }
===================
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Apps APIs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-apps-apis?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to