示例#1
0
        public string GetAccessToken(string userMailId)
        {
            IZohoPersistenceHandler persistenceHandler = ZohoOAuth.GetPersistenceHandlerInstance();

            ZohoOAuthTokens tokens;

            try
            {
                ZCRMLogger.LogInfo("Retreiving access token..");
                tokens = persistenceHandler.GetOAuthTokens(userMailId);
            }
            catch (Exception e) when(!(e is ZohoOAuthException))
            {
                ZCRMLogger.LogError("Exception while fetching tokens from persistence" + e);
                throw new ZohoOAuthException(e);
            }
            try
            {
                return(tokens.AccessToken);
            }
            catch (ZohoOAuthException)
            {
                ZCRMLogger.LogInfo("Access Token expired, Refreshing Access token");
                tokens = RefreshAccessToken(tokens.RefreshToken, userMailId);
            }
            return(tokens.AccessToken);
        }
示例#2
0
        //TODO: Throw ZohoOAuthException ;
        public string GetAccessToken(string userMailId)
        {
            IZohoPersistenceHandler persistenceHandler = ZohoOAuth.GetPersistenceHandlerInstance();

            ZohoOAuthTokens tokens;

            try{
                Console.WriteLine("Getting tokens");
                tokens = persistenceHandler.GetOAuthTokens(userMailId);
            }catch (Exception e) {
                Console.WriteLine("Exception while retrieving tokens from persistence " + e.Message);
                throw;
            }
            try
            {
                return(tokens.AccessToken);
            }catch (Exception e) {
                Console.WriteLine(e.Message);
                ZCRMLogger.LogInfo("Access Token expired, Refreshing Access token");
                tokens = RefreshAccessToken(tokens.RefreshToken, userMailId);
            }
            return(tokens.AccessToken);
        }