Mautic Community Forums

Error on requesting access_token and access_token_secret through API

Hi,



I am trying to integrate Mautic with our CRM (sugarcrm). I get the below error while requesting access_token and access_token_secret through API



Array ( [error] => Array ( [message] => signature_invalid => 401 ) ) .

This is my code. Please help. I wrote to mautic-support about 10 days back but still to hear from them.

Code*****

<?php if(!defined('sugarEntry'))define('sugarEntry', true); if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); require_once('include/entryPoint.php'); global $sugar_config; include __DIR__ . '/vendor/autoload.php'; require_once 'modules/Configurator/Configurator.php'; use MauticAuthApiAuth; $publicKey = ''; $secretKey = ''; $callback = ''; $settings = array( 'baseUrl' => $sugar_config['mautic_baseURL'], 'version' => 'OAuth1a', // Version of the OAuth can be OAuth2 or OAuth1a. OAuth2 is the default value. 'clientKey' => '44nak5j6p000w08cw8ks440sksk0skooc0gk8kw48wc00o0wo0',//$sugar_config['mautic_clientKey'], 'clientSecret' => '68f4xbltpgg0swkskc84sccoo0woc0oog4gcsc08wws0oosckw',//$sugar_config['mautic_clientSecret'], 'callback' => $sugar_config['mautic_callback'] ); session_start(); $auth = ApiAuth::initiate($settings); $auth->enableDebugMode(); if ($auth->validateAccessToken()) { if ($auth->accessTokenUpdated()) { $accessTokenData = $auth->getAccessTokenData(); $configurator = new Configurator(); $configurator->loadConfig(); $configurator->config['mautic_accessToken'] = $accessTokenData['access_token']; $configurator->config['mautic_accessTokenSecret'] = $accessTokenData['access_token_secret']; $configurator->saveConfig(); } } echo '
';print_r($accessTokenData);echo '

'; echo '
';print_r($auth);echo '

'; ?>[code] => 401 ) ) .

This is my code. Please help. I wrote to mautic-support about 10 days back but still to hear from them.

******************Code***********************

<?php
if(!defined('sugarEntry'))define('sugarEntry', true);
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
require_once('include/entryPoint.php');
global $sugar_config;
include __DIR__ . '/vendor/autoload.php';
require_once 'modules/Configurator/Configurator.php';

use MauticAuthApiAuth;

$publicKey = '';
$secretKey = '';
$callback = '';

$settings = array(
'baseUrl' => $sugar_config,
'version' => 'OAuth1a', // Version of the OAuth can be OAuth2 or OAuth1a. OAuth2 is the default value.
'clientKey' => '44nak5j6p000w08cw8ks440sksk0skooc0gk8kw48wc00o0wo0',//$sugar_config,
'clientSecret' => '68f4xbltpgg0swkskc84sccoo0woc0oog4gcsc08wws0oosckw',//$sugar_config,
'callback' => $sugar_config
);

session_start();

$auth = ApiAuth::initiate($settings);
$auth->enableDebugMode();
if ($auth->validateAccessToken()) {
if ($auth->accessTokenUpdated()) {
$accessTokenData = $auth->getAccessTokenData();
$configurator = new Configurator();
$configurator->loadConfig();
$configurator->config = $accessTokenData;
$configurator->config = $accessTokenData;
$configurator->saveConfig();
}
}
echo '
';print_r($accessTokenData);echo '

';
echo '
';print_r($auth);echo '

';

?>

Hi,

I am trying to integrate Mautic with our CRM (sugarcrm). I get the below error while requesting access_token and access_token_secret through API

Array ( [error] => Array ( [message] => signature_invalid [code] => 401 ) ) .

This is my code. Please help. I wrote to mautic-support about 10 days back but still to hear from them.

Code*****

<?php if(!defined('sugarEntry'))define('sugarEntry', true); if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); require_once('include/entryPoint.php'); global $sugar_config; include __DIR__ . '/vendor/autoload.php'; require_once 'modules/Configurator/Configurator.php'; use MauticAuthApiAuth; $publicKey = ''; $secretKey = ''; $callback = ''; $settings = array( 'baseUrl' => $sugar_config['mautic_baseURL'], 'version' => 'OAuth1a', // Version of the OAuth can be OAuth2 or OAuth1a. OAuth2 is the default value. 'clientKey' => '44nak5j6p000w08cw8ks440sksk0skooc0gk8kw48wc00o0wo0',//$sugar_config['mautic_clientKey'], 'clientSecret' => '68f4xbltpgg0swkskc84sccoo0woc0oog4gcsc08wws0oosckw',//$sugar_config['mautic_clientSecret'], 'callback' => $sugar_config['mautic_callback'] ); session_start(); $auth = ApiAuth::initiate($settings); $auth->enableDebugMode(); if ($auth->validateAccessToken()) { if ($auth->accessTokenUpdated()) { $accessTokenData = $auth->getAccessTokenData(); $configurator = new Configurator(); $configurator->loadConfig(); $configurator->config['mautic_accessToken'] = $accessTokenData['access_token']; $configurator->config['mautic_accessTokenSecret'] = $accessTokenData['access_token_secret']; $configurator->saveConfig(); } } echo '
';print_r($accessTokenData);echo '

'; echo '
';print_r($auth);echo '

'; ?>