salesforce-marketingcloud / FuelSDK-PHP

FuelSDK-PHP
MIT License
134 stars 142 forks source link

[BUG] Authentication fails on newly created packages using Legacy authentication #146

Closed danniehansen closed 5 years ago

danniehansen commented 5 years ago

Describe the bug When creating a new SFMC package with legacy authentication, authentication no longer works using FuelSDK. Instead of correctly getting authenticated it throw a error

Unable to validate App Keys(ClientID/ClientSecret) provided.: Unable to validate App Keys(ClientID/ClientSecret) provided, requestToken response:{"message":"Unauthorized","errorcode":1,"documentation":""}

Using a older SFMC package client id / secret works perfectly.

To Reproduce

  1. Create a new package with legacy authentication
  2. Add 'Data extension' read/write
  3. Copy & paste client id/secret into configuration of FuelSDK
  4. Try & fetch list of data extensions.

Expected behavior Expected it to properly return a list of available data extensions.

Screenshots None

Code snippet

$client = new ET_Client(!file_exists('soap.xml')', false, array(
        'clientid' => 'xxx',
        'clientsecret' => 'xxx',
        'xmlloc' => 'soap.xml',
      ));

$getDE = new ET_DataExtension();
    $getDE->authStub = $client;
    $getDE->props = array('CustomerKey', 'Name');
    $getResult = $getDE->get();

die(print_r($getDE));

Environment

The bug has the severity

Additional context Already wrote it further up. But it appears older packages work without issues but is consistent on new packages where it fails. I cannot find any information that indicates that the API has changed. Legacy authentication should be supported for a few months more to my knowledge.

sfdrogojan commented 5 years ago

Hi @danniehansen!

It looks like you are missing some config params from the 3rd parameter. Adapt the example bellow to your needs:

$client = new ET_Client(!file_exists('soap.xml'), false, array(
            'appsignature' => 'none',
            'clientid' => 'YOUR_CLIENT_ID',
            'clientsecret' => 'YOUR_CLIENT_SECRET',
            'defaultwsdl' => 'https://webservice.exacttarget.com/etframework.wsdl',
            'xmlloc' => 'soap.xml',
            'baseUrl' => 'YOUR_REST_TSE',
            'baseAuthUrl' => 'YOUR_AUTH_TSE',
            'baseSoapUrl' => 'YOUR_SOAP_TSE',
      ));
danniehansen commented 5 years ago

Hi @sfdrogojan,

I'm getting the same thing after defining all of those additional params. Strange thing is though that even without these params it worked for other configurations for older packages. But lately when creating new packages the error i reported started occurring.

ghost commented 5 years ago

Hi, @danniehansen!

I just created a new package in my Marketing Cloud account that uses the legacy authentication. Here is what I further did in order to test what might be happening:

  1. Copied the CampaignTest.php test class and renamed it to PhpIssueTest.php
  2. Replaced this

$this->client = new ET_Client(true);

with this:

$this->client = new ET_Client(false, false, array( 'appsignature' => 'none', 'clientid' => 'YOUR_CLIENT_ID', 'clientsecret' => 'YOUR_CLIENT_SECRET', 'defaultwsdl' => 'https://webservice.exacttarget.com/etframework.wsdl', 'xmlloc' => '/some/path/to/cache/ExactTargetWSDL.xml', 'baseUrl' => 'YOUR_REST_TSE', 'baseAuthUrl' => 'YOUR_AUTH_TSE', 'baseSoapUrl' => 'YOUR_SOAP_TSE'));

  1. Ran the PhpIssueTest.php tests.

The authentication succeeds (checked in Fiddler Web Debugger), all four tests are passing. My guess is that you are using both theparamsconstructor parameter and you also have aconfig.phpfile that is overwriting some of the parameters that you provided in the constructorparamsparameter.

danniehansen commented 5 years ago

@sfcbetiuc

Hi,

Sorry for the late response. That's really odd. Tried doing something similar.

  1. Created a new directory
  2. Ran composer init
  3. Added fuelsdk
  4. Creates a test.php file containing (with x replaced):
<?php
require __DIR__ . '/vendor/autoload.php';

use FuelSdk\ET_Client;
use FuelSdk\ET_DataExtension;

$client = new ET_Client(!file_exists('soap.xml'), false, array(
  'appsignature' => 'none',
  'clientid' => 'x',
  'clientsecret' => 'x',
  'defaultwsdl' => 'https://webservice.exacttarget.com/etframework.wsdl',
  'xmlloc' => 'soap.xml',
  'baseUrl' => 'x',
  'baseAuthUrl' => 'x',
  'baseSoapUrl' => 'x',
));

$getDE = new ET_DataExtension();
$getDE->authStub = $client;
$getDE->props = array('CustomerKey', 'Name');
$getResult = $getDE->get();

if (!empty($getResult->results)) {
  foreach ($getResult->results as $result) {
    print_r($getResult->results); die();
  }
}
  1. Opened the file in the browser.

Which resulted in the exact same issue. I've attached a screenshot of the configuration of the package. But it's the same as other packages that do work.

Screen Shot 2019-06-28 at 11 03 53 AM

danniehansen commented 5 years ago

@sfcbetiuc

Hi Again,

Appears to be a IP restriction of the API calls. Thank you for looking into the issue. It was simply a configuration issue it appears.