The OAuth Apps API enables you to manage OAuth apps for a Wix Headless project or site. An OAuth app authorizes an external client app or site, on any platform, to authenticate with a Wix site or project and manage its data using the Wix JavaScript SDK.
With the OAuth Apps API, you can:
- Create a new OAuth app to enable an external client to access a Wix project or site.
- Query and retrieve information about existing OAuth apps.
- Update details of an existing OAuth app.
- Delete an OAuth app.
To use Wix Headless functionality you need to create an OAuth app, either using the OAuth Apps API or in the project or site's dashboard. For instructions on how to do this, see how to Set Up Authorization for Wix Headless.
Once you have created an OAuth app, learn how to Set Up the Wix JavaScript SDK for Wix Headless.
It's important to note the following points before starting to code:
- Each external client should authenticate using its own OAuth app.
- You can only generate a secret once for each OAuth app, and the secret can't be retrieved later. Store the secret securely.
- After you delete an OAuth app, an external client can no longer make API calls by authenticating with its client ID.
- Connect a custom template on any platform to an existing Wix project
- Change allowed redirect domains for an external client app or site
- Prevent an existing client app or site from connecting to a Wix project
- OAuth app: An intermediary application that authorizes and authenticates an external client to access data on a Wix project or site.
- Project: A Wix business backend incorporating Wix business solutions, but which doesn't necessarily have a Wix site frontend.
- Client: An external app or site, built on any platform, which accesses or manages data on a Wix project or site using Wix APIs.
- Client ID: A unique ID that an external client uses to authenticate for making API calls.
- Client secret: A unique credential that an external client uses to authenticate for admin access to a Wix project or site.
This article shares some possible use cases your app could support, as well as a sample flow that could support each use case. This can be a helpful jumping off point as you plan your app's implementation.
You can create a frontend template, on an external platform, that takes advantage of business solutions on a Wix project.
For any external app or site to access a Wix project's data, it must be authorized in advance by creating an OAuth app. To enable project owners to connect a site or app built on your template to their existing Wix project data, follow these steps:
- Create a template on any platform and integrate API calls from the Wix JavaScript SDK to access and manage business solutions in a Wix project.
- Create a Wix app that a project owner can install.
- Make sure your app requests the Manage OAuth Apps permission scope.
- Obtain the domain name for the deployment of the site or app built on the template.
- In your app code, call Create OAuth App. Specify a
name
and optionaldescription
that identify the client clearly. In theallowedDomains
array, provide the deployment domains from the previous step. - Store the returned OAuth app's
id
securely. - Assign the ID to a secure environment variable in the template code. The template can now access the Wix project's data.
Whenever an external client redirects a user to Wix for authentication, the client provides a URL for Wix to redirect the user back to after authentication. To ensure security, Wix only redirects the user if the domain has been approved in advance in the OAuth app's settings. To update an external client's approved URLs, follow these steps:
- Make sure you have the OAuth app ID for the external client.
- Obtain a complete list of domains to approve for the external site or app.
- Call Update OAuth App with the OAuth app ID as a path parameter. Pass all approved domains in the
oAuthApp.allowedDomains
body parameter, and pass["allowedDomains"]
in themask.paths
body parameter. - The external app or site can now provide any redirect URL from the updated list.
To prevent a client site or app from accessing a Wix project's data, you can disable its permissions by deleting the OAuth app it connects through. To delete the OAuth app, follow these steps:
- Obtain the OAuth app ID used by the client app or site.
- Call Delete OAuth App with the OAuth app ID as a path parameter.
- The client app or site can no longer connect to the Wix project. If you wish to reactivate its connection in future, create a new OAuth app with Create OAuth App and update the OAuth app ID used in the client app or site code.
The following table shows field support for filters and sorting for the OAuthApp object:
Field | Supported Filters | Sortable |
---|---|---|
id | $eq | |
createdDate | Sortable | |
name | Sortable |
Related content: API Query Language, Query OAuth Apps endpoint
Creates a new OAuth app for a Wix Headless client.
Permission Scopes
For app development, you must have one of the following permission scopes:Syntax
Retrieves an OAuth app by ID.
Permission Scopes
For app development, you must have one of the following permission scopes:Syntax
Updates an OAuth app.
Only fields provided in mask.paths
are updated.
You can update the following fields:
name
description
allowedDomain
loginUrl
Permission Scopes
For app development, you must have one of the following permission scopes:Syntax
Retrieves a list of OAuth apps, given the provided paging, filtering, and sorting.
Query OAuth Apps runs with these defaults, which you can override:
- Results are sorted by
id
in descending order. paging.offset
is0
.
For field support for filters and sorting, see OAuth Apps: Supported Filters and Sorting
To learn about working with Query endpoints in general, see API Query Language.
Permission Scopes
For app development, you must have one of the following permission scopes:Syntax
Triggered when an OAuth app is created.
Event Body
Triggered when an OAuth app is updated.
Event Body
Triggered when an OAuth app is deleted.