Setup Instructions:
-
Create Azure AD Application:
- Go to Azure Portal → App Registrations → New Registration
- Set redirect URI to
http://localhost:8000/callback - Add client secret and note down CLIENT_ID & CLIENT_SECRET
-
Install requirements:
pip install gradio msal python-dotenv requests msgraph-sdk- Create
.envfile:
CLIENT_ID=your_azure_client_id
CLIENT_SECRET=your_azure_client_secret
Features:
- Modern Gradio interface with emoji icons
- File/folder navigation with breadcrumbs
- Upload/download functionality
- Folder creation/delete operations
- Responsive design with theme support
- Secure token management
- Real-time updates
Key Improvements and Integrations:
- Hybrid Architecture
- Combines REST API direct calls (from reference code) with OOP wrapper class
- Maintains SDK-like convenience while keeping transparency of API operations
- Enhanced Authentication Flow
- Interactive authentication sequence with automatic token refresh
- Secure state management instead of global variables
- Complete OAuth 2.0 code flow with PKCE support
- Modern UI Features
- Hybrid tabbed/navigation interface combining both approaches
- Visual folder breadcrumbs
- Interactive file tree with type icons
- Multiple file upload support
- Improved Error Handling
- Automatic token refresh on 401 errors
- Detailed operation logging
- Visual feedback for all actions
- Advanced Features
- Full folder navigation history with stack
- Type-safe API request handler
- Multi-threaded upload capability
- Responsive layout with collapsible panels
- Security Enhancements
- Secure token storage in session state
- Environment variable configuration
- No persistent credential storage
- Extended Operations
- Drag-and-drop file upload
- Batch operations
- Contextual navigation
- Detailed metadata display
To use this improved version:
- Install requirements:
pip install gradio requests msal python-dotenv
python onedrive_gradio_r1-v2.py- Configure Azure AD app with:
- Redirect URI:
http://localhost:8000/callback - API permissions: Files.ReadWrite.All, User.Read, offline_access
- Create
.envfile with your credentials:
CLIENT_ID=your_app_id
CLIENT_SECRET=your_app_secret
This implementation combines the structured approach of the original code with the explicit API control of the reference code while adding modern UI elements and robust error handling.