OneDrive Setup Guide
This guide will walk you through the process of setting up OneDrive authentication for FileSyncHub.
Prerequisites
- A Microsoft Account
- Access to Azure Portal
- FileSyncHub installed on your system
Step 1: Register Your Application
- Go to the Azure Portal
- Navigate to “Azure Active Directory”
- Select “App registrations” in the left sidebar
- Click “New registration”
- Fill in the application details:
- Name: “FileSyncHub”
- Supported account types: “Personal Microsoft accounts only”
- Redirect URI: Select “Public client/native” and enter
http://localhost:8080
- Click “Register”
Step 2: Configure API Permissions
- In your app registration, go to “API permissions”
- Click “Add a permission”
- Select “Microsoft Graph”
- Choose “Delegated permissions”
- Add the following permissions:
Files.ReadWrite
offline_access
- Click “Add permissions”
Step 3: Get Application Credentials
- Note down your “Application (client) ID” from the overview page
- Go to “Authentication” in the left sidebar
- Under “Advanced settings”:
- Enable “Allow public client flows”
- Set “Default client type” to “Yes”
- Click “Save”
Step 4: Configure FileSyncHub
- Create a configuration file for OneDrive:
mkdir -p ~/.config/filesynchub/credentials
- Create
~/.config/filesynchub/credentials/onedrive.json
with your client ID:{ "client_id": "your-client-id-here", "redirect_uri": "http://localhost:8080" }
Step 5: First-Time Authentication
- Run FileSyncHub with the TUI interface:
filesynchub sync --tui
- The application will initiate the OneDrive authentication process
- Follow the authentication prompts in your browser
- Grant the requested permissions
- Return to FileSyncHub
Troubleshooting
Common Issues
- Authentication Failed
- Error: “AADSTS error”
- Solution: Verify your client ID and ensure all permissions are correctly configured
- Connection Timeout
- Error: “Connection timed out”
- Solution: Check your internet connection and try again
- Invalid Redirect URI
- Error: “Invalid redirect URI”
- Solution: Ensure the redirect URI in your configuration matches the one in Azure Portal
Security Best Practices
- Keep your client ID secure
- Never commit credentials to version control
- Use environment variables when possible
- Regularly review application permissions
Advanced Configuration
Environment Variables
You can use environment variables instead of configuration files:
export FILESYNCHUB_ONEDRIVE_CLIENT_ID="your-client-id"
export FILESYNCHUB_ONEDRIVE_REDIRECT_URI="http://localhost:8080"
Custom Endpoints
For special cases (e.g., OneDrive for Business), you can configure custom endpoints:
{
"client_id": "your-client-id",
"redirect_uri": "http://localhost:8080",
"authority_url": "https://login.microsoftonline.com/your-tenant-id"
}