OAuth Setup
Durian supports OAuth 2.0 for Microsoft 365 and Google/Gmail.
Microsoft 365
Durian can use a built-in Microsoft OAuth app by default. If you want to use your own Azure app (recommended for organizations), follow the steps below and set client_id in your config. Otherwise, you can skip app registration and omit client_id (the default will be used).
- Go to Azure Portal → App registrations → New registration
- Name: “Durian Mail” (or anything)
- Supported account types: “Accounts in any organizational directory”
- Redirect URI: Web →
http://localhost:8080/callback - Go to API Permissions → Add permissions:
offline_accesshttps://outlook.office.com/SMTP.Sendhttps://outlook.office.com/IMAP.AccessAsUser.All
- Grant admin consent (required for work/school accounts)
- Copy Application (client) ID
Add to config.pkl (custom app):
oauth {
provider = "microsoft"
client_id = "your-client-id"
// tenant = "common" // Optional: "common", "organizations", or your tenant ID/domain
}Shared mailboxes: configure the shared mailbox as its own [[accounts]] entry and set auth_email to the delegating user who has Full Access + Send As.
Google OAuth tokens expire every 7 days while the app is in “Testing” mode in Google Cloud Console. You will need to re-authenticate periodically with
durian auth login. This is a Google limitation for unverified apps (see #147).- Go to Google Cloud Console → APIs & Services → Credentials
- Create project (if needed)
- Configure OAuth consent screen (External, add your email as test user)
- Create credentials → OAuth client ID → Web application
- Authorized redirect URI:
http://localhost:8080/callback - Copy Client ID and Client Secret
Add to config.pkl:
oauth {
provider = "google"
client_id = "your-client-id"
client_secret = "your-client-secret"
}Usage
durian auth login you@company.com # Opens browser for OAuth (email or alias)
durian auth status # Show all accounts + token status
durian auth refresh you@company.com # Manual token refresh
durian auth logout you@company.com # Remove token from KeychainTokens are stored securely in macOS Keychain and auto-refresh when near expiry.
Troubleshooting
| Error | Solution |
|---|---|
client_secret is missing | Add client_secret to config (required for Google) |
redirect_uri_mismatch | Ensure redirect URI is exactly http://localhost:8080/callback |
invalid_grant | Token expired, run durian auth login again |
AADSTS50011 | Redirect URI not registered in Azure Portal |