I can authenticate the REST API through Postman, but I've tried both the python FuelSDK and C# SDK but I can't seem to get either of them to connect to my instance of Marketing Cloud. I think I'm just getting the endpoints wrong.

Installed Packages

This is what my installed packages look like: Installed Packages


Postman seems to work, when I send the following request to https://blah.auth.marketingcloudapis.com/v2/token

{ "grant_type": "client_credentials"
, "client_id": "..."
, "client_secret": "..."
, "scope": "data_extensions_read data_extensions_write"
, "account_id": "..." }

The response is:

    "access_token": "...",
    "token_type": "Bearer",
    "expires_in": 1079,
    "scope": "data_extensions_read data_extensions_write",
    "soap_instance_url": "https://blah.soap.marketingcloudapis.com/",
    "rest_instance_url": "https://blah.rest.marketingcloudapis.com/"

So I think postman works.

C# FuelSDK

However not in C#. I installed v1.1.1 of the FuelSDK through NuGet. When I try running the following code in C#:

var client = new ETClient(new NameValueCollection {
    { "clientId", "CLIENTID" },
    { "clientSecret", "SECRET" },
    { "authEndPoint", "https://blah.auth.marketingcloudapis.com/v2/token" },
    { "soapEndPoint", "https://blah.soap.marketingcloudapis.com/" },
    { "restEndPoint", "https://blah.rest.marketingcloudapis.com/" },

I get an exception on that line:

System.Net.WebException "The remote server returned an error: (400) Bad Request."

When I change the authEndPoint to https://blah.auth.marketingcloudapis.com/ I get:

"The remote server returned an error: (596) ."

When I remove authEndPoint all together I get:

"The remote server returned an error: (401) Unauthorized."

Python FuelSDK

My ~/.fuelsdk/config.python looks like this:

[Web Services]
appsignature: none
clientid: CLIENTID
clientsecret: CLIENTSECRET
defaultwsdl: https://blah.soap.marketingcloudapis.com/ETFramework.wsdl
baseapiurl: https://www.marketingcloudapis.com
authenticationurl: https://blah.auth.marketingcloudapis.com/v2/token
soapendpoint: https://blah.soap.marketingcloudapis.com/
wsdl_file_local_loc: /tmp/ExactTargetWSDL.s6.xml

When I run the following code:

client = FuelSDK.ET_Client()

I get the following error:

Exception: Unable to validate App Keys(ClientID/ClientSecret) provided:
'error': 'unsupported_grant_type',
'error_description': 'Use "authorization_code" or "refresh_token" or "client_credentials" or "urn:ietf:params:oauth:grant-type:jwt-bearer" as the grant_type.',
'error_uri': 'https://developer.salesforce.com/docs'

When I change authenticationurl to https://blah.auth.marketingcloudapis.com/ I get the following exception:

  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

When I remove authenticationurl, I get the following exception:

Exception: Unable to validate App Keys(ClientID/ClientSecret) provided: {'message': 'Unauthorized', 'errorcode': 1, 'documentation': ''}

I'm at wit's end, does anyone know what the problem is?

4 Answers 4


I was running into the same issue and i looked at client.py. Looks like it was setup only to handle v1/requestToken and not v2/token. So i tried to edit the client.py to make sure the grant_type and client_id and client_secret is passed over then hand to change the response variables it was parsing. Even after all that my response was Post response:False Code: HTTPStatus.OK Message: Error: API Permission Failed. Result Count: 0 Results: []

  • Sadly I think you're right, I ended up downloading the source code, and it was too out of date I didn't know where to start... Apr 25, 2019 at 2:25

I had the same issue. FuelPHP seems to be outdated and full of bugs, so I'm sending my requests directly with CURL...

Here's a working example:

    $server = "https://blablabla.auth.marketingcloudapis.com/v2/token";
$json = json_encode(array('client_id' => 'YOUR-CLIENT-ID','client_secret' => 'YOUR-CLIENT-SECRET','grant_type' => 'client_credentials'));
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('POST / HTTP/1.1','Content-Type: application/json','Content-Length: '.strlen($json)));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $server);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
$raw = curl_exec($ch);
$error = curl_error($ch);
$response = json_decode($raw, true);

The C# Fuel SDK has been updated to handle the new oAuth 2.0 process


Try these? It works for me

  1. When you instantiate the client, declare 'useOAuth2Authentication' as 'True'
  2. Remove v2/token from the authentication url

Like this in Python

stubObj = ET_Client.ET_Client(
  False, False,
      'clientid': '<CLIENT_ID>',
      'clientsecret': '<CLIENT_SECRET>',
      'defaultwsdl': 'https://webservice.exacttarget.com/etframework.wsdl',
      'authenticationurl': 'https://blah.auth.marketingcloudapis.com/',
      'baseapiurl': '<REST TENANT SPECIFIC ENDPOINT>',
      'soapendpoint': '<SOAP TENANT SPECIFIC ENDPOINT>',
      'wsdl_file_local_loc': r'<WSDL_PATH>/ExactTargetWSDL.xml',
      'useOAuth2Authentication': 'True',
      'accountId': '<TARGET_ACCOUNT_ID>',
      'scope': '<PERMISSION_LIST>'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .