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 the
https
-based ngrok URLs (i.e.https://my-url.ngrok.io/
) to set the App homepage URL and the Redirect URI with the values below (as an example):- 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
.
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: