This tutorial guides you through setting up an OAuth 2.0 authentication flow. This flow allows users to grant limited permissions to your App and enables your App to request an access token to perform actions on behalf of the user.
By the end of this tutorial, your Webflow App will be able to obtain an access token on behalf of a user using the Authorization Code Grant flow.
Webflow uses the Authorization Code Grant flow to provide access tokens to Apps. This flow involves a series of interactions between Webflow’s authorization server and your web app. Here’s how the process works when a user visits your site for the first time:
code parameter to the query string.code to make a secure request to Webflow’s authorization server to obtain an access token. If the request is valid, Webflow responds with an access token.Before you begin, ensure you have the following:
client_id and client_secret.Before you can request an access token, you’ll need to set up your server to handle the OAuth 2.0 flow. We recommend using JavaScript or Python, as we provide SDKs for these languages that can help simplify the authentication process.
Follow the below examples in Node.js or Python to help you create a server that can accept requests and communicate with the Webflow authorization server.
Install the necessary packages
Ensure all required libraries and dependencies are installed.
Store environment variables
Create a .env file to store your sensitive information like the CLIENT_ID and CLIENT_SECRET.
Initialize server
Set up the server to listen on a specific port.
To enable users to install your App, you need to create an authorization link. This link directs users to a Webflow authorization screen where they can grant your App permission to access their Webflow data.
App Marketplace Submission: Supply this link in your application to the App marketplace. Users will use it to install your App from the marketplace.
Your Site: Place this link on your site to direct users to try out or install your App.
You can create the authorization link using various methods, with the recommended approach being through our JavaScript and Python SDKs.
To create the authorization link, you will need the following information:
Unique ID for your application. Can be found in the dashboard.
This value should always be “code”.
The URI to redirect the user once they’ve granted authorization. This must match what’s used in your App settings.
A token value provided by your application to prevent CSRF attacks. If passed, the authorization server should respond with this parameter.
Verify that the scopes requested in this Install/OAuth URL are equal to or a subset of the scopes configured for your app in the app settings. If there’s a mismatch where the Install URL requests scopes beyond what’s configured in the app settings, users won’t be able to install your app and an error will be displayed.
To simplify the process of creating authorization links and handling OAuth flows, you can use the provided JavaScript and Python SDKs. These SDKs offer convenient methods to generate the authorization URL with the required parameters.
If you prefer not to use the SDKs, you can manually construct the authorization link by adding the necessary query parameters to the authorization URL:
Construct the authorization URL using the gathered parameters:
%20).scope:action, so the colon (:) should be encoded as %3A.For example passing the following scopes: sites:read, sites:write, and pages:read should look like sites%3Aread%20sites%3Awrite%20pages%3Aread
Additionally, you can copy an auto-generated installation link from your App’s settings.
In your Workspace Dashboard:

When users click on the authorization link, they will be taken to a screen where they can review and grant the necessary permissions for your App.

After the user authorizes the App, Webflow redirects them to your server using the redirect URI specified in your App settings. This GET request to your server includes the following query parameters:
code - A single-use authorization code that you’ll exchange for an access token. This code is only valid for 15 minutes.state : optional - The unique state value you provided in the initial request. Ensure this value matches the original to protect against CSRF attacks.Let’s set up an endpoint to handle the callback request and store these parameters, as you’ll need them in the next step to request an access token from Webflow.
See the example below for details on completing the following steps:
state parameter
Optionally, check that the state parameter matches the one sent in the authorization request.Now that you have the authorization code you can exchange it for an access token. The access token request should be made as soon as possible after authorization as an unconfirmed authorization code is only valid for 15 minutes.
Let’s walk through the steps to create a smooth flow for a user:
Request an access token from Webflow’s authorization server
In the same endpoint we just set up, create a request to Webflow with the following parameters. Webflow requires these parameters to ensure that the entity requesting the access token is the same entity that received the authorization code.
POST https://api.webflow.com/oauth/access_token
Unique ID for your application. Can be found in the dashboard.
Private value unique to your application. Can be found in the dashboard.
Authorization code used to retrieve an access_token for the user. Can only be used once.
Store the access token securely
For demonstration purposes, we’re storing the access token in a variable and printing it to the terminal. However, this approach isn’t secure for production. You should store the access token securely in a database or environment variables. For comprehensive guidance on securely storing tokens, please refer to our example apps on GitHub.
Redirect the user within your App
After successfully obtaining the access token, redirect the user to an appropriate location within your app. This could be a dashboard, a welcome page, or any other relevant section. Ensure that the user experience is smooth and they’re informed about the successful authentication.
You’re ready to test your newly created authentication flow! In this step, we’ll start our server, navigate to the authorization screen, and get an access token from Webflow.
Create a secure tunnel using ngrok (OPTIONAL)
ngrok can be used to create a secure tunnel to your localhost, providing you with an HTTPS link that can be used as a valid redirect URI.
Ngrok will provide you with a public HTTPS URL that forwards to your local server running on port 3000. It should look something like this:
Update your redirect URI in your App’s settings
In your workspace settings, navigate to Apps & Integrations > App Development
Find your App and click the “Edit App” button
Navigate to the “Building Blocks” menu
Update the Redirect URI with your Ngrok URL, ensuring that you include the correct endpoint. For example, if your endpoint is /callback, your Redirect URI should look something like https://your-ngrok-url.ngrok.io/callback.
Update the redirect URI in your .env file
Be sure to also update your redirect URI in your .env file if you’re passing your callback URI when creating an authorization link.
Start your server Enter the following command into your terminal to start your server.
Start the authorization flow
http://localhost:3000/auth. You will be redirected to Webflow’s authorization screen for your App.Didn’t see what you expected? Read the troubleshooting guide below.
To revoke an access token that has been issued to your application, make a POST request to the following endpoint with the below parameters:
The unique identifier for your OAuth application.
The secret key associated with your OAuth application.
The access token that you wish to revoke.
If the request is successful, the access token will be revoked, and the response will return an HTTP status code of 200 OK with the following response body:
client_id is correct and matches the one provided in your app’s settings.redirect_uri parameter, verify that it matches the one registered for your app in the dashboard.redirect_uri in your authorization link, you must also include it in your request for an access token.client_id and client_secret.code value, these tokens are single-use and can not be used again. Also, the token is only valid for 15 minutes after it has been granted.