Exemple #1
0
        public static string GetAuthToken(GA.Lib.AdWordsUser user, bool generateNew = false)
        {
            string pass;
            string auth;

            auth = GetAuthFromDB((user.Config as GA.Lib.AdWordsAppConfig).Email, out pass);

            //Set User Password
            (user.Config as GA.Lib.AdWordsAppConfig).Password = pass;

            if (generateNew)
            {
                auth = GetAuthFromApi(user);
            }

            return(string.IsNullOrEmpty(auth) ? GetAuthFromApi(user) : auth);
        }
Exemple #2
0
        private static string GetAuthFromApi(GA.Lib.AdWordsUser user)
        {
            string auth;

            try
            {
                auth = new AuthToken(
                    (user.Config as GA.Lib.AdWordsAppConfig),
                    GA.Lib.AdWordsSoapClient.SERVICE_NAME,
                    (user.Config as GA.Lib.AdWordsAppConfig).Email,
                    (user.Config as GA.Lib.AdWordsAppConfig).Password).GetToken();

                SaveAuthTokenToDB((user.Config as GA.Lib.AdWordsAppConfig).Email, auth);
            }
            catch (Exception ex)
            {
                Log.Write("AdwordsUtill", "Error while trying to create new Auth key", ex);
                throw new Exception("Error while trying to create new Auth key", ex);
            }
            return(auth);
        }