8 August, 2022

Solution for “Invalid OAuth access token” in Magento Facebook App

If you have encountered the “Invalid oAuth token error” while saving a product in the Magento Catalog Page, please follow the below steps to get rid of the error:

Please confirm whether the CURL function is enabled in your server. If it is not been enabled, please contact your hosting provider to enable the CURL function in your server.

If still the problem persist,

Go to your Magento root path and find the below file
app/code/local/apptha/facebookapp/model/Observer.php
and find the public function get_app_token($appid, $appsecret)

now replace the existing code

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, ‘Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9.1.1) Gecko/20090715 Firefox/3.5.1′);
$r = curl_exec($ch);

with

$r = file_get_contents($url);
( please ensure that the allow_url_fopen is enabled in PHP.INI configuration file. The line shows as “allow_url_fopen = On”)

Checkout : How to setup your Magento ecommerce store on Facebook

Share

Selvakumar is Tech Lead with experience in developing Magento, Joomla, WordPress themes and extensions. He has published lots of posts on ecommerce store set up, front-end and back end coding, storefront customization, etc. He is also specialized in database management and debugging skills.

Leave a Reply

Your email address will not be published. Required fields are marked *