xero-api fbq is not defined in live site

25 views Asked by At

Here is the code I am using to initiate connection with Xero. I have a dev site set up in WSL that can run this code successfully. When I transfer it to the live site, I am prompted to "Allow Access" but it does not reach the callback, instead the same page reloads and the console shows "Uncaught ReferenceError: fbq is not defined" error in "authorize.xero.com". It seems the issue is related to google tag manager?

As a result I cannot complete the connection. It seems the callback is never reached. I have confirmed the callback url is correct in the app as well as in the xero developer console.

As stated this code is working fine in my Dev application.

Any assistance would be appreciated.

function initauth() {

    $env = XeroEnv();

    // Xero OAuth2 parameters
    $client_id = $env['client_id'];
    $redirect_uri = $env['re_directURI'];
    $scope = 'openid profile email files accounting.transactions accounting.settings'; 
    $state = bin2hex(random_bytes(16));

    // Xero authorization endpoint
    $auth_url = 'https://login.xero.com/identity/connect/authorize';

    // Construct the authorization URL with query parameters
    $authorizationUrl = sprintf(
        "%s?response_type=code&client_id=%s&redirect_uri=%s&scope=%s&state=%s",
        $auth_url,
        urlencode($client_id),
        urlencode($redirect_uri),
        urlencode($scope),
        $state
    );

    header('Location: ' . $authorizationUrl);

    exit;

}

function XeroEnv() {
    return [
        "client_id" => "xxxx",
        "client_secret" => "xxxx",
        "tenantId" => "xxx",
        "re_directURI" => "https://www.mydomain.net.au/xero/callback",
    "scopes" => "offline_access accounting.transactions openid profile email accounting.contacts accounting.settings",
    ];
}

error in console

0

There are 0 answers