HomeGuidesAPI Reference
ChangelogHelp CenterCommunityContact Us
Guides

Migrate to OAuth from private key authentication

Switch to OAuth to ensure your app is discoverable in Klaviyo's app marketplace.

You will learn

If you’re here, it’s likely that your Klaviyo app uses private key authentication. We now require all of our published partners to use OAuth when integrating with Klaviyo. This guide covers how you can migrate and the benefits you’ll get in doing so.

📘

Migrating to OAuth will not break your app. Your integration will continue to work as expected.

Why update to OAuth?

❗️

Your app will be delisted if you do not upgrade to OAuth. Only apps using OAuth will be considered for inclusion in Klaviyo's App Marketplace.

Switching your app from private key authentication to OAuth allows for greater exposure to our customers, simpler integration workflows, and access to all new items our R&D team is developing. Here are some benefits you’ll get from the switch:

  • Increased marketplace and in-product visibility

    Maintain exposure to 150,000+ customers by keeping your app listed and discoverable on the App Marketplace. We expect there to be roughly 5-10x more unique visitors to the App Marketplace due to new improvements.

  • App-branded event metrics

    Say goodbye to the generic gear icon and get branded exposure on the Klaviyo platform!

  • Seamless integration

    Streamline the integration process to as little as a few clicks, ensuring a smooth experience for customers, increasing adoption and satisfaction rates.

  • Marketing & enablement opportunities

    Eligibility for inclusion in marketing newsletters and other enablement initiatives.

  • Exclusive API access

    Unlock powerful API features, including our Universal Content and Webhooks APIs.

📘

Check out our YouTube video on Why create an app with Klaviyo for more information.

How to migrate to OAuth

If your app was previously published using private key authentication, we estimate that a single engineer will need 1-2 sprints (2-4 weeks) to complete the migration to OAuth. When migrating to OAuth, each step listed below should take roughly 1 week:

  1. OAuth implementation
    • Create your OAuth app. Please note that after creation, your app will require at least 5 active users to meet our listing requirements before submission.
    • Ensure you properly handle refresh tokens and token expiration.
    • Start completing our Testing & Review Template .
  2. UI and OAuth workflow updates
  3. Security and documentation
  4. Review and submission

❗️

Within 3 months of migrating your app to OAuth, you should migrate all customers currently using private key authentication to your OAuth app. This transition will offer enhanced security and an improved product experience for our shared customers.

Your fast track migration plan

We've built a working OAuth demo in Flask to help you expedite your migration. Follow the steps below to get started.

1. Get your Klaviyo OAuth app credentials

  1. Go to your Klaviyo Developer Console
  2. Create an OAuth app
  3. Add the redirect URL: http://localhost:5000/auth/callback
  4. Add the following scopes: accounts:read profiles:read
  5. Grab your Client ID and Client Secret

2. Clone the demo project

First, run the following code to set up your virtual environment.

mkdir klaviyo-oauth-demo && cd klaviyo-oauth-demo
python3 -m venv .venv
source .venv/bin/activate
pip install flask requests python-dotenv

You can access the demo Python code here. Save the provided code sample as oauth_flow.py and create a .env.local file with your credentials:

CLIENT_ID=your_client_id_here
CLIENT_SECRET=your_client_secret_here
REDIRECT_URI=http://localhost:5000/auth/callback
KLAVIYO_SCOPES="accounts:read profiles:read"
FLASK_SECRET_KEY=super-secret-for-local-dev  
# Note: for production, do not hardcode FLASK_SECRET_KEY.
# Instead, generate a strong random GUID/hex string and import via a secure env var or secrets manager.

3. Run the OAuth flow locally

Start the server:

python oauth_flow.py

Kick off the flow in your browser: http://localhost:5000/auth/start

You'll log into Klaviyo, grant consent, and immediately get back your access token and refresh token in JSON.

4. Refresh tokens automatically

We've built a /auth/refresh endpoint to handle token rotation for you:

curl -X POST http://localhost:5000/auth/refresh \
  -H "Content-Type: application/json" \
  -d '{"refresh_token": "YOUR_REFRESH_TOKEN"}'

This ensures you'll never run into expired token issues.

5. Test real Klaviyo API calls

Use the /whoami endpoint with your access token to hit Klaviyo's API directly:

curl -X GET http://localhost:5000/whoami \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

This verifies end-to-end that your migration works.

What this means for your team

  • Engineering leaders: You don't need to commit weeks of dev time. With our starter code, your teams can cut migration down to a few days.
  • Security & compliance: OAuth eliminates key sprawl, enables scoped permissions, and simplifies audits.
  • Future-proofing: This is the industry standard. Your engineers will integrate faster with other modern systems once OAuth is the norm.

How to productionize your OAuth migration

The demo code gets you from private key → OAuth in minutes. But before rolling this into production, here are the must-dos for a secure, scalable integration:

1. Store tokens in your database

Save both the access token and refresh token securely in your database, encrypted at rest. Record expires_in (or calculate expires_at) so you can proactively refresh before expiry.

2. Handle token expiry gracefully

Every Klaviyo API call must include the access token in the Authorization: Bearer <token> header. If you receive a 401 Unauthorized, your access token has expired. At that point:

  1. Use the refresh token to request a new access token
  2. Save the new tokens to your DB
  3. Retry the original API call transparently

This ensures a seamless experience with no downtime for your users.

3. Migrate your existing users

Any users who are using the private key integration will need to re-authenticate using OAuth. Build a simple re-authentication flow into your app to request consent from each user. Once migrated, you can deprecate private key support entirely.

4. Metrics auto migration

Good news: any metrics previously tracked via private keys will automatically migrate to branded metrics. This means your data continuity is preserved, and you get all the benefits of OAuth without losing visibility. Learn more about branded metrics here.

Additional resources