Google Services Dashboard with login
import logging
from gunicorn.app.base import BaseApplication
from app_init import app
# IMPORT ALL ROUTES
from routes import *
# Setup logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
class StandaloneApplication(BaseApplication):
def __init__(self, app, options=None):
self.application = app
self.options = options or {}
super().__init__()
def load_config(self):
# Apply configuration to Gunicorn
for key, value in self.options.items():
if key in self.cfg.settings and value is not None:
self.cfg.set(key.lower(), value)
Frequently Asked Questions
Enabling faster onboarding of new employees who need access to company Google resources Q3: What are the security implications of using this dashboard for business data?
The template implements several security best practices: - Uses OAuth 2.0 for secure authentication - Implements token refresh mechanisms to maintain secure connections - Stores sensitive data in a SQLite database with proper encryption - Provides user-specific data isolation through session management - Includes built-in authentication to prevent unauthorized access
Q4: How can I modify the template to add support for additional Google services? A: You can extend the template by adding new OAuth scopes and routes. Here's an example for adding Google Drive support:
```python
Add to GMAIL_OAUTH_SCOPES in routes.py
OAUTH_SCOPES = [ 'https://www.googleapis.com/auth/gmail.readonly', 'https://www.googleapis.com/auth/drive.readonly' # Add Drive scope ]
Add new route for Drive integration
@app.route("/drive_files") def drive_files_route(): if 'user' not in session: return redirect(url_for('landing_route'))
user = User.query.filter_by(email=session['user']['user_email']).first()
cloud_connection = get_valid_cloud_connection(user.id, 'gmail')
if cloud_connection:
credentials = Credentials.from_authorized_user_info({
'access_token': cloud_connection.access_token,
'refresh_token': cloud_connection.refresh_token
})
drive_service = build('drive', 'v3', credentials=credentials)
# Implement Drive functionality here
```
Q5: How can I customize the token refresh mechanism for different expiration times?
A: The token refresh mechanism in the Google Services Dashboard can be customized by modifying the check_token_expiry
function in utils.py
:
```python def check_token_expiry(cloud_connection, threshold_minutes=5): """ Customizable token expiry checker Args: cloud_connection: The cloud connection object threshold_minutes: Minutes before expiry to trigger refresh """ if not cloud_connection.token_expiry: return True
expiry_threshold = datetime.utcnow() + timedelta(minutes=threshold_minutes)
return cloud_connection.token_expiry <= expiry_threshold
```
You can then call this function with different threshold values based on your needs: ```python
Check 30 minutes before expiry
if check_token_expiry(connection, threshold_minutes=30): refresh_google_token(connection) ```
Created: | Last Updated:
Google Services Dashboard with Login Template Guide
This template provides a ready-to-use dashboard for connecting to Google services like Gmail, Drive, and Calendar. It includes built-in authentication and allows users to securely connect their Google accounts.
Getting Started
- Click "Start with this Template" to begin using the template in Lazy Builder
Initial Setup
Before testing the app, you'll need to set up Google Cloud credentials:
- Go to the Google Cloud Console
- Create a new project or select an existing one
- Enable the Gmail API for your project
- Go to "Credentials" in the left sidebar
- Click "Create Credentials" and select "OAuth 2.0 Client ID"
- Choose "Web application" as the application type
- Add these authorized redirect URIs:
- Your Lazy app URL +
/gmail_callback
- Your Lazy app URL +
/login/callback
- Click "Create"
- Copy the generated Client ID and Client Secret
In the Lazy Builder Environment Secrets tab, add:
* GOOGLE_CLIENT_ID
: Your Google Cloud OAuth client ID
* GOOGLE_CLIENT_SECRET
: Your Google Cloud OAuth client secret
Testing the App
- Click the "Test" button in Lazy Builder
- Lazy will provide a server URL where your dashboard is hosted
Using the Dashboard
- Visit the provided server URL
- Click "Get Started" on the landing page
- Sign in with your Google account
- Once authenticated, you'll see the main dashboard
- Click "Connect Google Account" to authorize access to Gmail
- After connecting, you can manage your Google services through the dashboard
The dashboard provides: * Single sign-on authentication * Secure Google account connection * Access to Gmail data (additional Google services can be added by extending the scopes) * Mobile-responsive interface
This template serves as a foundation for building applications that need to interact with Google services while maintaining secure user authentication and data access.
Template Benefits
- Rapid Google Service Integration
- Enables quick development of applications that need to access Google services
- Reduces integration time from weeks to hours with pre-built OAuth flows
-
Perfect for businesses needing to build custom Google Workspace tools
-
Enhanced Security & Compliance
- Built-in authentication and authorization mechanisms
- Secure token management and automatic refresh functionality
-
User data isolation ensuring privacy and compliance with data protection regulations
-
Multi-User Support for Enterprise
- Supports multiple user accounts with individual Google service connections
- Perfect for team collaboration tools and enterprise applications
-
Scalable architecture suitable for both small teams and large organizations
-
Cost-Effective Development
- Eliminates the need for expensive third-party integration services
- Reduces development time and associated costs
-
Minimizes technical debt with well-structured, maintainable code
-
Versatile Business Applications
- Can be adapted for email management systems
- Suitable for document management applications with Google Drive
- Ideal for calendar scheduling and automation tools
- Perfect starting point for custom CRM systems with Google integration
Technologies





