> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# ConnectByOAuth

# Package: conferencing

# Namespace: ConferencingProvider

# Method link: https://dev.wix.com/docs/api-reference/business-management/calendar/conferencing/conferencing-provider-v1/connect-by-o-auth.md

## Introduction

Starts an OAuth connection between a resource and your provider.

Wix calls this method when a user chooses to connect their provider account by OAuth. Wix calls it only if your configuration lists `OAUTH` in `connectionMethods`.

Wix uses the returned `oauthUrl` to redirect the user to your provider's authorization screen.

*Your implementation should:**
- Generate and return your provider's OAuth URL.
- Host the OAuth callback, create the connection (generating its `id`), and redirect the user back to `redirectUrl` with `?connectionId=<id>` on success, or `?error=<code>` on failure. Defined failure codes: `reject` (the user denied access), `missing_permissions` (the user didn't grant all required scopes), and `internal` (token exchange, user-info fetch, or other unexpected error).

*Error handling:** If your implementation returns an error, Wix surfaces it to the caller.

---

## REST API

### Schema

```
 Method: connectByOAuth
 Description: Starts an OAuth connection between a resource and your provider.  Wix calls this method when a user chooses to connect their provider account by OAuth. Wix calls it only if your configuration lists `OAUTH` in `connectionMethods`.  Wix uses the returned `oauthUrl` to redirect the user to your provider's authorization screen.  *Your implementation should:** - Generate and return your provider's OAuth URL. - Host the OAuth callback, create the connection (generating its `id`), and redirect the user back to `redirectUrl` with `?connectionId=<id>` on success, or `?error=<code>` on failure. Defined failure codes: `reject` (the user denied access), `missing_permissions` (the user didn't grant all required scopes), and `internal` (token exchange, user-info fetch, or other unexpected error).  *Error handling:** If your implementation returns an error, Wix surfaces it to the caller.
 URL: {DEPLOYMENT-URI}/v1/connect-by-oauth
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  resourceId
 Method parameters: 
   param name: redirectUrl | type: redirectUrl | description: URL to redirect the user to after OAuth completes, with `?connectionId=xxx` on success or `?error=xxx` on failure. Either an `http` or `https` URL, or an app-scheme URL (`wixadmin://`, `wix://` or `branded.<metaSiteId>://`) when the flow starts in a mobile app.  | validation: maxLength 2048
   param name: resourceId | type: resourceId | description: GUID of the resource to connect. Treat it as an opaque, stable Wix identifier that you key the connection by. | required: true | validation: format GUID
 Return type: ConnectByOAuthResponse
  - name: oauthUrl | type: string | description: OAuth URL to redirect the user to.  | validation: format WEB_URL


```

### Examples

### Start an OAuth connection
Wix sends the request payload as an encoded JWT. For the purposes of this example, we show the request and response objects decoded.

```curl
curl -X POST \
'https://my-conferencing.example.com/v1/connect-by-oauth' \
-H 'user-agent: Wix' \
-H 'Content-Type: text/plain; charset=utf-8' \
-d '{
  "resourceId": "a1f3c9e2-6b7d-4e58-9c0a-2d4b8e7f1356",
  "redirectUrl": "https://www.example.com/conferencing/oauth-callback"
}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.calendar.conferencingProvider.connectByOAuth(request, metadata)
 Description: Starts an OAuth connection between a resource and your provider.  Wix calls this method when a user chooses to connect their provider account by OAuth. Wix calls it only if your configuration lists `OAUTH` in `connectionMethods`.  Wix uses the returned `oauthUrl` to redirect the user to your provider's authorization screen.  *Your implementation should:** - Generate and return your provider's OAuth URL. - Host the OAuth callback, create the connection (generating its `id`), and redirect the user back to `redirectUrl` with `?connectionId=<id>` on success, or `?error=<code>` on failure. Defined failure codes: `reject` (the user denied access), `missing_permissions` (the user didn't grant all required scopes), and `internal` (token exchange, user-info fetch, or other unexpected error).  *Error handling:** If your implementation returns an error, Wix surfaces it to the caller.
 Method parameters:
   param name: request | type: ConnectByOAuthRequest    
        - name: redirectUrl | type: string | description: URL to redirect the user to after OAuth completes, with `?connectionId=xxx` on success or `?error=xxx` on failure. Either an `http` or `https` URL, or an app-scheme URL (`wixadmin://`, `wix://` or `branded.<metaSiteId>://`) when the flow starts in a mobile app.  | validation: maxLength 2048
        - name: resourceId | type: string | description: GUID of the resource to connect. Treat it as an opaque, stable Wix identifier that you key the connection by.  | validation: format GUID
   param name: metadata | type: Context | description: this message is not directly used by any service, it exists to describe the expected parameters that SHOULD be provided to invoked Velo methods as part of open-platform. e.g. SPIs, event-handlers, etc.. NOTE: this context object MUST be provided as the last argument in each Velo method signature.  Example: ```typescript export function wixStores_onOrderCanceled({ event, metadata }: OrderCanceledEvent) { ... } ```  
        - name: requestId | type: string | description: A unique identifier of the request. You may print this GUID to your logs to help with future debugging and easier correlation with Wix's logs.  
        - name: currency | type: string | description: [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) 3-letter currency code.  | validation: format CURRENCY
        - name: identity | type: IdentificationData | description: An object that describes the identity that triggered this request.  
           - ONE-OF: 
              - name: anonymousVisitorId | type: string | description: GUID of a site visitor that has not logged in to the site.  | validation: format GUID
              - name: memberId | type: string | description: GUID of a site visitor that has logged in to the site.  | validation: format GUID
              - name: wixUserId | type: string | description: GUID of a Wix user (site owner, contributor, etc.).  | validation: format GUID
              - name: appId | type: string | description: GUID of an app.  | validation: format GUID
        - name: languages | type: array<string> | description: A string representing a language and region in the format of `"xx-XX"`. First 2 letters represent the language code according to ISO 639-1. This is followed by a dash "-", and then a by 2 capital letters representing the region according to ISO 3166-2. For example, `"en-US"`.  
        - name: instanceId | type: string | description: The service provider app's instance GUID.  | validation: format GUID
 Return type: PROMISE<ConnectByOAuthResponse>
  - name: oauthUrl | type: string | description: OAuth URL to redirect the user to.  | validation: format WEB_URL


```

### Examples

### Start an OAuth connection
Returns your provider's OAuth URL. Your callback creates the connection and redirects the user to `redirectUrl`.

```javascript
import { conferencingProvider } from "@wix/calendar/service-plugins";

conferencingProvider.provideHandlers({
  connectByOAuth: async (payload) => {
    const { request, metadata } = payload;
    const { redirectUrl, resourceId } = request;
    // Build your provider's authorization URL. Keep `redirectUrl` and `resourceId` for your OAuth callback.

    return {
      oauthUrl:
        "https://zoom.us/oauth/authorize?response_type=code&client_id=Wq7kTn2bRZ6xY1pVhD3s&redirect_uri=https%3A%2F%2Fmy-conferencing.example.com%2Foauth%2Fcallback&state=8f3d2b6a",
    };
  },
});

/* Promise resolves to:
 * {
 *   "oauthUrl": "https://zoom.us/oauth/authorize?response_type=code&client_id=Wq7kTn2bRZ6xY1pVhD3s&redirect_uri=https%3A%2F%2Fmy-conferencing.example.com%2Foauth%2Fcallback&state=8f3d2b6a"
 * }
 */

```

### connectByOAuth (self-managed)
Self-managed SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { conferencingProvider } from '@wix/calendar/service-plugins';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { conferencingProvider },
  // Include the auth strategy and host as relevant
});


async function connectByOAuth(request,metadata) {
  const response = await myWixClient.conferencingProvider.connectByOAuth(request,metadata);
};
```

---