This code sample demonstrates how to implement authentication using ID Tokens in a Webflow Hybrid App. It provides a starting point for setting up authentication middleware, server-side logic, and integrating with a Designer Extension frontend.
Before setting up this project in your local dev environment, follow these steps:
- Setup ngrok locally, which will allow you to proxy localhost server ports to a public-facing
https
-based URL- Sign up for a free ngrok account
- Setup ngrok on your machine
- Run
ngrok http 3000
to expose your localhost3000
port at a generated URL (or your own port specified in.env
)
- Register a Webflow App
- Ensure to toggle both Designer extension and Data client APIs to "On"
- Set the following "scopes"/building block permissions:
- Authorized user: Read-only
- Sites: Read and Write
- Use dummy URLs (i.e.
https://my-url.ngrok.io/
) to set the App homepage URL and the Redirect URI with the values below (we'll replace with Ngrok-provided URLs shortly):- App homepage url: https://my-url.ngrok.io/
- Redirect URI: https://my-url.ngrok.io/callback
To run the application, follow these steps:
- Clone this repository to your local machine.
- Install dependencies by running
npm install
. - Create a copy of the
.env.example
file and name it.env
. Fill the values for each of the variables outlined in the section below. - Start the application by running
npm run dev
. Note that a table should be printed on your terminal with the Development URLs and Redirect URI. - Back in the Webflow Workspace for App settings, set the
Redirect URI
to be the one listed in the terminal (i.e.https://8a75-73-168-29-191.ngrok-free.app/callback
) and save the settings. - Navigate to the root of that Ngrok URL (i.e.,
https://8a75-73-168-29-191.ngrok-free.app/
) and authorize the App for the site - You should be taken to the Designer on redirect. Open the Apps panel and select the App you've created and click "Launch development App" to get started and retrieve Site data
Ensure the following environment variables are configured. You can find these details in your Webflow workspace for your newly registered Webflow App:
WEBFLOW_CLIENT_ID
: Webflow Client IDWEBFLOW_CLIENT_SECRET
: Webflow Client SecretPORT
: (Optional) Specify a port for your server, otherwise it will serve at port3000
by default.
For more detailed instructions on setting up JWT middleware, configuring the server, and integrating with the Designer Extension frontend, please refer to the following guide: