Docs

External accounts

Let people connect Google and Yandex accounts and any mail or calendar server for the calendar and mail.

People can connect their Google or Yandex account, or any mail or calendar server with an app password, in Settings → Accounts. The federation server keeps the connection and works with the account on its own, so the calendar stays up to date even when all of a person's devices are off. Provider tokens never reach the devices; an app password is sent once, when connecting. On the server, tokens and passwords are stored encrypted with your key.

Without this setting nobody can connect an account.

Create a Google OAuth client

  1. In Google Cloud Console create a project and enable the Google Calendar API.
  2. Configure the OAuth consent screen: external, the app name, a support address and your domain as an authorized domain.
  3. Add the scopes openid, email and https://www.googleapis.com/auth/calendar.readonly, and for mail also https://mail.google.com/. Calendar access is a sensitive scope and mail access a restricted one: until Google verifies your app, only the test users you list on the consent screen can connect (up to 100).
  4. Create an OAuth client of type "Web application" with the redirect URI https://<your server>/accounts/oauth/callback.
  5. Save the client secret to a file only the server can read.

Create a Yandex OAuth app

  1. At oauth.yandex.ru create an app of type "Web services" with the redirect URI https://<your server>/accounts/oauth/callback.
  2. Give it the access login:info and login:email, and for mail also mail:imap_full and mail:smtp.
  3. Save the client secret to a file only the server can read.

Connecting with a password

This needs nothing from you: once the file is given, people can connect any IMAP/SMTP or CalDAV server with an app password. The server checks the password before it keeps it, and connects only to addresses on the public internet. If your people's mail server is on your own network, add "server_accounts": {"private_networks": true}; "server_accounts": {"enabled": false} turns password accounts off.

Create an encryption key

head -c 32 /dev/urandom | base64 > external-accounts-current.key
chmod 600 external-accounts-current.key

Keep the key with your database backups: without it, connected accounts cannot be read and people will have to connect them again.

Turn it on

Write a configuration file next to the keys:

{
  "secret_keys": ["external-accounts-current.key"],
  "google": {
    "client_id": "1234567890-abc.apps.googleusercontent.com",
    "client_secret_file": "google-client.secret"
  },
  "yandex": {
    "client_id": "0123456789abcdef0123456789abcdef",
    "client_secret_file": "yandex-client.secret"
  }
}

and start the server with --external-accounts=<file> (all options). With several server processes, every one needs the same file and keys.

Change the key

Put the new key first in secret_keys and keep the old one after it. Tokens move to the new key as they are refreshed. Remove the old key once every account has synchronized since; an account still sealed with a removed key asks its owner to connect it again.

Troubleshooting

What you seeWhat to do
Google says "Access blocked" or "app not verified"Add the person as a test user on the consent screen, or get the app verified.
Google says the redirect URI does not matchThe redirect URI of the OAuth client must be exactly https://<your server>/accounts/oauth/callback.
An account shows "Authorize again"Google refused the saved access: the password changed, access was removed in the Google account, or the test user was removed. The person authorizes it again in Settings → Accounts.
Server log external_account_sync_failedGoogle did not answer or answered an error; the server retries on its own, at least once an hour.

On this page