Troubleshooting your Magento 2 integration

read
Last updated at:

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 begin

If you have not already, read our guide on How to Integrate 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.

Ensure 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. 

  1. Ensure you have not password protected or IP restricted access to your store.
  2. Ensure that your store is accessible via HTTPS with a valid SSL certificate. You can test your certificate here.

Check your Magento 2 and Klaviyo extension versions

  1. If you are using Magento 2.2.0 or earlier, you will need to manually enable OAuth.
  2. Make sure you’ve installed and activated the Klaviyo extension version 3.0.3 or higher.

What version of the extension do I need?

Magento 2 Version Klaviyo Extension Version
2.4.0+

4.0.0+

2.3.4+

3.0.5 (minimum)
3.0.11 (maximum)

2.3.0 - 2.3.3

3.0.4

Below 2.3.0

2.2.0

Failure 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.

m2oauthfailed.png

In order to resolve this error, you will need to either:

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
  1. 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
  2. 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. 
    curloauthendpoint.png
  3. 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]

Ensure your firewall is not blocking Klaviyo’s requests

If you use a firewall or similar service, such as Cloudflare, it may block Klaviyo’s servers from accessing the relevant endpoints on your server.  When using a firewall, add a rule to your firewall to whitelist the Klaviyo user agent. All Klaviyo’s requests have the user agent header Klaviyo/1.0

Delete 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.

  1. Within Magento, navigate to Systems
  2. Select Integrations
  3. 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.

Additional Resources

Reviewing Your Magento 2 Data
Guide to Supporting Multiple Magento Stores (for Magento 2.x)

x
Was this article helpful?
1 out of 1 found this helpful