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:
Postman
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?