def getOAuthTokens(self, userEmail): try: connection = self.getDBConnection() cursor = connection.cursor() sqlQuery = "SELECT useridentifier,accesstoken,refreshtoken,expirytime FROM oauthtokens where useridentifier='" + userEmail + "'" cursor.execute(sqlQuery) row_count = 0 for (useridentifier, accesstoken, refreshtoken, expirytime) in cursor: row_count = row_count + 1 try: from .OAuthClient import ZohoOAuthTokens except ImportError: from OAuthClient import ZohoOAuthTokens return ZohoOAuthTokens(refreshtoken, accesstoken, expirytime, useridentifier) if row_count == 0: raise Exception('No rows found for the given user') except Exception as ex: import logging OAuthLogger.add_log( "Exception occured while fetching oauthtokens from DB ", logging.ERROR, ex) raise ex finally: cursor.close() connection.close()
def get_oauthtokens(self, userEmail): try: import os import pickle try: from .OAuthClient import ZohoOAuthTokens except ImportError: from OAuthClient import ZohoOAuthTokens responseObj = None if not os.path.isfile(self.file_path): raise Exception('Token Persistence File is not found') with open(self.file_path, 'rb') as fp: while True: try: oAuthObj = pickle.load(fp) if (userEmail == oAuthObj.userEmail): responseObj = ZohoOAuthTokens( oAuthObj.refreshToken, oAuthObj.accessToken, oAuthObj.expiryTime, oAuthObj.userEmail) break except EOFError: break if responseObj is None: raise Exception('No tokens found for the given user') return responseObj except Exception as ex: import logging OAuthLogger.add_log( "Exception occured while fetching oauthtokens from File ", logging.ERROR, ex) raise ex
def getOAuthTokens(self, userEmail): try: import pickle try: from .OAuthClient import ZohoOAuth, ZohoOAuthTokens from .OAuthUtility import ZohoOAuthConstants except ImportError: from OAuthClient import ZohoOAuth, ZohoOAuthTokens from OAuthUtility import ZohoOAuthConstants import os os.chdir(ZohoOAuth.configProperties[ ZohoOAuthConstants.TOKEN_PERSISTENCE_PATH]) responseObj = ZohoOAuthTokens(None, None, None, None) if not os.path.isfile(ZohoOAuthConstants.PERSISTENCE_FILE_NAME): return responseObj with open(ZohoOAuthConstants.PERSISTENCE_FILE_NAME, 'rb') as fp: while True: try: oAuthObj = pickle.load(fp) if (userEmail == oAuthObj.userEmail): responseObj = oAuthObj break except EOFError: break return responseObj except Exception as ex: import logging OAuthLogger.add_log( "Exception occured while fetching oauthtokens from File ", logging.ERROR, ex) raise ex
def get_oauthtokens(self,userEmail): try: import os import pickle try: from .OAuthClient import ZohoOAuthTokens except ImportError: from OAuthClient import ZohoOAuthTokens responseObj=ZohoOAuthTokens(None,None,None,None) if not os.path.isfile(self.file_path): return responseObj with open(self.file_path, 'rb') as fp: while True: try: oAuthObj=pickle.load(fp) if(userEmail==oAuthObj.userEmail): responseObj=oAuthObj break except EOFError: break return responseObj except Exception as ex: import logging OAuthLogger.add_log("Exception occured while fetching oauthtokens from File ",logging.ERROR,ex) raise ex