This article shares a possible use case your implementation could support, as well as a sample flow. You're not limited to this use case, but it can be a helpful jumping off point for your planing.
External calendar providers use different methods for authenticating a connection. Some use an OAuth flow, while others require a user’s credentials (email address and password). To check the appropriate connection method for a provider:
- Call the List Providers endpoint to retrieve details about all supported external calendar providers.
- The response contains an array with details about each external calendar provider. Find the provider you want to connect with.
- Save the
id
for the provider you want to connect with.
- Check the
features.connectMethods
array for the chosen provider. If the array contains OAUTH
, you can connect by OAuth. If the array contains CREDENTIALS
, you can connect by credentials.
Before you can sync events with a Wix site user’s external calendar, you need to establish a connection with the external calendar. If the external provider supports connecting by credentials, create the connection as follows:
- Get the email address and password associated with the external calendar account from the user.
- If you don’t already have the ID of the external calendar provider you want to connect to, use List Providers to get it.
- Use List Schedules to get the ID for the schedule to connect the external calendar with.
- Call the Connect By Credentials endpoint with the details and credentials you’ve collected.
- The response includes a
connection
object with details of the new external calendar connection. If the connection was established successfully, the connection’s status
is CONNECTED
.
- Use Update Sync Config to configure the connection and enable importing and/or exporting events.
Before you can sync events with a Wix site user’s external calendar, you need to establish a connection with the external calendar. If the external provider supports connecting by OAuth, create the connection as follows:
- If you don’t already have the ID of the external calendar provider you want to connect to, use List Providers to get it.
- Use List Schedules to get the ID for the schedule to connect the external calendar with.
- Call the Connect By OAuth endpoint using the details you’ve collected. The
redirectUrl
parameter should include the URL the user is redirected to after authorizing access to their external calendar.
- The response includes a URL for the external calendar authorization page. Redirect the user to this page.
- The user authorizes access to their external calendar.
- The connection is now established. The user is redirected to the URL provided in
redirectUrl
, with the connection ID as a query parameter.
- Retrieve details about the newly established external calendar connection, including its ID, using the Get Connection endpoint.
- Use Update Sync Config to configure the connection and enable importing and/or exporting events.
To retrieve an aggregated list of events in connected external calendars during a particular time range:
- Create a connection with each of the user’s external calendars, following the steps above.
- Use the List Events endpoint with the relevant start and end times to retrieve an aggregated list of events in all the user’s connected external calendars.