Mautic Community Forums

Giving service unavailable error when try to get token from mautic

Check my code bellow
<?php
require DIR.’/vendor/autoload.php’;

use Mautic\Auth\OAuthClient;

$consumerKey = “<consumerKey>”;
$consumerSecret = “<consumerSecret>”;
$callback = “http://php7.indusnet.cloud/rakeshc/moutic-test/index.php”;

try{
$oauthObject = \Mautic\Auth\ApiAuth::initiate(
array(
‘baseUrl’ => “http://php7.indusnet.cloud/rakeshc/moutic-test”,
‘version’ => ‘OAuth1a’,
‘consumerKey’ => $consumerKey,
‘consumerSecret’ => $consumerSecret,
‘callback’ => $callback,
// ‘scope’ => $scope
)
);

// $oauthObject-&gt;setAccessTokenDetails($_SESSION[$auth]);

$oauthObject-&gt;enableDebugMode();

if ($oauthObject-&gt;validateAccessToken()) {
    //Was the access token updated?
    if ($oauthObject-&gt;accessTokenUpdated()) {
        $auth1 = $oauthObject-&gt;getAccessTokenData();
        echo $auth1;exit;
    }
    $auth1 = $oauthObject-&gt;getAccessTokenData();
    echo "<pre>";
    print_r($auth1);
    echo "</pre>";
    exit;
} else {
	echo "string";exit;
}

} catch(Exception $e) {
print_r($e->getMessage());exit;
}