4.4 KiB
4.4 KiB
SharePoint Configuration Guide
This guide will help you get the configuration values needed to connect to SharePoint.
Quick Answer: Where to Get Configuration Values
1. SharePoint Site URL
- Go to your SharePoint site in a browser
- Copy the URL from the address bar
- Example:
https://yourcompany.sharepoint.com/sites/YourSiteName - Important: Include
/sites/SiteNameif it's a subsite
2. Folder Path
- Navigate to the folder containing your Excel files in SharePoint
- Right-click the folder → "Copy path" or "Details"
- Example:
/Shared Documents/Reportsor/sites/YourSite/Shared Documents/Vendor Reports - Tip: In SharePoint, go to the folder, click "..." menu → "Copy link" and extract the path
3. Azure AD App Credentials (Recommended Method)
Step 1: Register App in Azure AD
- Go to Azure Portal
- Navigate to Azure Active Directory → App registrations
- Click New registration
- Name it (e.g., "Vendor Report Generator")
- Select Accounts in this organizational directory only
- Click Register
Step 2: Create Client Secret
- In your app, go to Certificates & secrets
- Click New client secret
- Add description (e.g., "Vendor Report Secret")
- Choose expiration (recommend 24 months)
- Click Add
- IMPORTANT: Copy the Value immediately (you won't see it again!)
- This is your
client_secret
- This is your
Step 3: Get Client ID
- In your app, go to Overview
- Copy the Application (client) ID
- This is your
client_id
- This is your
Step 4: Grant SharePoint Permissions
- In your app, go to API permissions
- Click Add a permission
- Select SharePoint
- Choose Application permissions (not Delegated)
- Select Sites.Read.All (or Sites.ReadWrite.All if you need write access)
- Click Add permissions
- Click Grant admin consent (important!)
- Wait for status to show "Granted for [Your Organization]"
4. Alternative: User Credentials (Less Secure)
If you can't use app authentication:
username: Your SharePoint/Office 365 emailpassword: Your password (not recommended for automation)
Complete Configuration Example
Once you have all values, add them to config.yaml:
sharepoint:
enabled: true
site_url: "https://yourcompany.sharepoint.com/sites/YourSite"
folder_path: "/Shared Documents/Reports" # Path to your Excel files folder
local_dir: "reports" # Where to save downloaded files
use_app_authentication: true # Use app auth (recommended)
client_id: "12345678-1234-1234-1234-123456789abc" # From Azure AD
client_secret: "your-secret-value-here" # From Azure AD (the Value, not Secret ID!)
file_pattern: "*.xlsx" # Only download Excel files
overwrite: true # Overwrite existing files
Testing Your Configuration
-
Test SharePoint connection:
python sharepoint_downloader.py -
Or use the Web UI:
- Start:
python web_ui.py - Open:
http://localhost:8080 - Click "Update Data from SharePoint"
- Check for errors
- Start:
Common Issues
"SharePoint authentication failed"
- Check: Client ID and secret are correct
- Check: App has been granted admin consent
- Check: Permissions are "Application permissions" (not Delegated)
"Folder not found"
- Check: Folder path is correct (case-sensitive)
- Tip: Use SharePoint's "Copy path" feature
- Check: Path starts with
/(e.g.,/Shared Documents/...)
"No files downloaded"
- Check: Folder contains Excel files (
.xlsxor.xls) - Check: File pattern matches your files
- Check: You have read permissions to the folder
"Access denied"
- Check: App has
Sites.Read.Allpermission - Check: Admin consent has been granted
- Check: App is registered in the same tenant as SharePoint
Security Best Practices
- Use App Authentication (not user credentials)
- Store secrets securely:
- Use environment variables in production
- Never commit
config.yamlwith secrets to git - Use a secrets manager for production
- Limit permissions: Only grant
Sites.Read.All(not write access unless needed) - Rotate secrets: Update client secrets regularly
Getting Help
If you're stuck:
- Check the terminal/console for detailed error messages
- Verify each configuration value step by step
- Test with a simple folder first (one Excel file)
- Check Azure AD app status in Azure Portal