You will learn
Learn how to solve issues with your Magento 2 OAuth setup by following the troubleshooting steps described below. If you are still encountering issues after running through these steps, please reach out on our Community or to our Support Team.
Before you beginBefore you begin
If you have not already, read our guide on Getting started with Magento 2 for step-by-step instructions to set up your Magento 2 integration.
Klaviyo uses the OAuth protocol to generate an access token and retrieve data from your Magento 2 store. If you’ve customized your Magento 2 installation, it can cause Klaviyo’s OAuth procedure to fail. This article will guide you through a series of troubleshooting steps to identify where the failure is occurring.
General troubleshooting stepsGeneral troubleshooting steps
Ensure your site is publicly accessible with a valid SSL certificateEnsure your site is publicly accessible with a valid SSL certificate
Klaviyo’s OAuth procedure requires that your website is publicly accessible, otherwise the necessary API calls to generate the access tokens will fail.
- Ensure you have not password protected or IP restricted access to your store.
- Ensure that your store is accessible via HTTPS with a valid SSL certificate. You can test your certificate here.
Ensure your firewall is not blocking Klaviyo’s requests
All outbound Klaviyo integration traffic is behind a set of predictable, static IP addresses so that you can have a high level of confidence that this traffic is coming from Klaviyo. Read our article to learn how to allowlist Klaviyo integration traffic IP addresses.
Check your Magento 2 and Klaviyo extension versionsCheck your Magento 2 and Klaviyo extension versions
- If you are using Magento v2.2.0, you'll need to manually enable OAuth.
- Make sure you’ve installed the correct Klaviyo extension (you may need to upgrade).
Ensure OAuth endpoints are accessible
You may have extra or missing rewrite rules which can make the default Magento 2 OAuth endpoints inaccessible. Klaviyo needs to access these endpoints to generate the necessary credentials for the authorization process.
Ensure that URLs below are accessible for your store:
https://[Store URL]/oauth/token/request
https://[Store URL]/oauth/token/access
- You can validate that they’re accessible by making a POST request like this:
curl --location --url 'https://[Store URL]/oauth/token/request' --request 'POST' -v
curl --location --url 'https://[Store URL]/oauth/token/access' --request 'POST' -v
- You should expect a response similar to the following. It is normal to see an error when making a request in this manner, and it validates the endpoints are responding correctly.
- If you do not receive a response related to OAuth, you should check that there are no redirects, invalid rewrite rules, or internal server errors preventing access to these URLs.
This can be caused by a store subpath in your URL. Test for a store subpath issue by accessing the endpoints at:
https://[Store URL]/[Store Path]/oauth/token/request
https://[Store URL]/[Store Path]/oauth/token/access
If these endpoints resolve, then include the below rewrite rules in your .htaccess file to solve the issue.
RewriteEngine on
RewriteRule /oauth/token/request$ https://%{HTTP_HOST}/[Store Path]/oauth/token/request [L,R=301]
RewriteRule /oauth/token/access$ https://%{HTTP_HOST}/[Store Path]/oauth/token/access [L,R=301]
Delete the integration and re-create itDelete the integration and re-create it
If you’ve made changes after a previous failed integration attempt, it is a good idea to delete the original OAuth integration. The keys used may be invalid and will need to be regenerated.
- Within Magento, navigate to Systems
- Select Integrations
- Locate the Klaviyo integration record and delete it
Once the integration record is deleted, follow the steps in our how to integrate with Magento 2 guide to create a new integration record and try again.
Magento version-specific issuesMagento version-specific issues
Failure specific to Magento 2.4.2Failure specific to Magento 2.4.2
If you’re using Magento 2.4.2, there is a known issue where OAuth activations fail. Upon activating the integration, you may see an error message like the one shown below. Even if you don’t receive the error, the OAuth activation may have failed. Normally, the error can be found in your Magento logs.
In order to resolve this error, you will need to either:
- Upgrade to Magento 2.4.3. View Magento 2's documentation to upgrade your version.
- Apply a patch as described on Klaviyo's github repository for Magento 2.
Authentication failure specific to Magento 2.4.6
Are you on Magento 2.4.6 and experiencing a 401 authentication error after integrating with Klaviyo? This could be due to a known Magento bug affecting Magento version 2.4.6. To solve this, you'll need to enable bearer token authentication so that Klaviyo can make requests using it (instead of OAuth 1.0). To enable bearer token authentication:
- In your Magento admin, navigate to Stores > Configuration > Services > OAuth > Consumer Settings.
- For the setting Allow OAuth Access Tokens to be used as stand-alone Bearer tokens, select Yes.
- Click Save Config.
After making this update, your previous authentication errors should resolve and integration syncs will resume.
Additional resourcesAdditional resources
Magento 2 data reference
Guide to supporting multiple Magento stores (for Magento 2.x)