A simple Flask application that demonstrates integration with QuickBooks Online API to create custom fields and attach those custom fields to invoices.
- OAuth 2.0 authentication with QuickBooks Online
- Create and read custom field from QuickBooks
- Attach invoice to custom fields
- Python 3.8 or higher
- QuickBooks Developer account with OAuth 2.0 credentials
-
Clone the Repository
git clone cd Custom-Fields-Python
-
Create Virtual Environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install Dependencies
pip install -r requirements.txt
4.Set environment variables
Create a .env
file with your QuickBooks credentials:
CLIENT_ID=your_client_id
CLIENT_SECRET=your_client_secret
REDIRECT_URI=your_redirect_uri
- Update
config.py
with your QuickBooks API credentials - Set up your QuickBooks Developer account and configure the OAuth2 redirect URI
- For local development, use ngrok to create a public URL:
ngrok http 5000
- Start the Flask Server
python app.py
- Access the Application
Access the application at
http://localhost:5000
- Click the "Connect to QuickBooks" button
- Log in to your QuickBooks account
- Authorize the application to access your QuickBooks data
- Enter a name for your custom field in the "Create Custom Field" section
- Click "Create Custom Field" to create a new custom field in QuickBooks
- Select a customer from the dropdown
- Select an item from the dropdown
- Enter the amount
- Select a custom field and enter its value
- Click "Create Invoice"
- View all active custom fields in the dashboard
- Deactivate custom fields using the provided interface
- Reactivate deactivated custom fields as needed
Custom-Fields-Python/
├── app.py # Main Flask application
├── config.py # Configuration settings
├── requirements.txt # Python dependencies
├── .env.template # Template for environment variables
├── static/ # Static assets (CSS, images)
│ ├── styles.css
│ └── images/
└── templates/ # HTML templates
└── index.html
- Never commit your
.env
file to version control - Keep your QuickBooks credentials secure
- Use environment variables for all sensitive information
- The
.env
file is automatically ignored by Git
-
Authentication Issues
- Ensure your OAuth credentials are correct in the
.env
file - Check that the redirect URI matches your QuickBooks app settings
- Verify admin is connecting to Quickbooks account
- Ensure your OAuth credentials are correct in the
-
Environment Setup Issues
- Make sure the
.env
file exists and contains all required variables - Verify that environment variables are being loaded correctly
- Check that the virtual environment is activated
- Make sure the
-
API Errors
- Check the application logs for detailed error messages
- Verify your QuickBooks subscription includes API access
- Ensure you're using the correct API endpoints for your QuickBooks environment
Feel free to submit issues and enhancement requests. For major changes, please open an issue first to discuss what you would like to change.