Zoho Cliq Message Search and [Credential Censor API] (https://github.com/prince11jose/credential_censor_api)
This project provides an API for searching messages in Zoho Cliq, analyzing them for sensitive credentials, and optionally censoring them by posting to specific channels. It includes features for obtaining access tokens using OAuth and securely managing Zoho API credentials.
- Search messages in Zoho Cliq using keywords.
- Analyze message content for sensitive information.
- Automatically post a response to a chat if sensitive content is detected.
- OAuth integration for Zoho Cliq with support for refresh tokens.
Python 3.8+ Zoho Developer account
git clone https://github.com/prince11jose/zc_message_search_api.git
cd zc_message_search_api
Create and activate a virtual environment to keep dependencies isolated.
python -m venv venv
source venv/bin/activate # On Windows, use `venv\Scripts\activate`
Install the required dependencies from requirements.txt:
pip install -r requirements.txt
Update the configuration file (config.ini) with your Zoho API credentials and the censor API endpoint:
[zoho]
company_id = YOUR_COMPANY_ID
client_id = YOUR_CLIENT_ID
client_secret = YOUR_CLIENT_SECRET
auth_code = YOUR_AUTH_CODE
refresh_token = YOUR_REFRESH_TOKEN
[censor_api]
endpoint = http://localhost:8000/detect_credentials
Credential Censor API needs to be hosed before the Zoho Cliq Message Search API is hosted.
- company_id: Your Zoho Cliq company ID.
- client_id: Client ID from Zoho API console.
- client_secret: Client Secret from Zoho API console.
- auth_code: Authorization code obtained from Zoho.
- refresh_token: Refresh token for obtaining new access tokens.
Start the Flask API server:
python app.py
- /search_and_post Method: POST Description: Searches messages in Zoho Cliq for specified keywords and analyzes them for credentials. Request Body:
{
"search_query": "username,password,pwd,pass"
}
You can use curl to interact with the /search_and_post endpoint:
curl --location --request POST 'http://127.0.0.1:5000/search_and_post' \
--header 'Content-Type: application/json' \
--data-raw '{"search_query": "username,password,pwd,pass"}'
Logging is configured to provide detailed information on the application's activities. Logs are written to both the console and a file named app.log.
- Log Levels: The default logging level is set to INFO. You can change this in config.py by modifying the level parameter in the setup_logging() function.
Authorization Code: The authorization code must be used immediately after obtaining it, as it expires quickly and can only be used once. Refresh Tokens: The script is configured to store and reuse refresh tokens, which simplifies obtaining access tokens without needing a new authorization code each time.
If you see an invalid_code error, the authorization code has likely expired or been used already. Generate a new authorization code and update config.ini accordingly.
project/
├── app.py # Main Flask application
├── api.py # ZohoCliqAPI class for interacting with Zoho Cliq APIs
├── config.py # Configuration and logging setup
├── config.ini # Configuration file for storing credentials
├── requirements.txt # Project dependencies
└── README.md # Project documentation
This project is licensed under the MIT License - see the LICENSE file for details.