function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Juan J RomeroJuan J Romero 

How to configure Auth. Provider and Named Credentials for Marketing Cloud?

Hello team,

I’m facing some issues trying to call Marketing Cloud REST API,  from SF Apex code, using Named Credentials, Auth Providers and Custom Metadata Types.
I have done the connection between the two systems, but making a request to obtain the access token every time I need to call the API or storing it in a custom setting, for example, to reuse it in future API calls.

I want to do it in a better way using Named Credentials, Auth Providers and Custom Metadata Types but I’m struggling with it. When my class extending Auth.AuthProviderPluginClass runs, it calls the method initiate but the method handleCallback is never called.

My questions are:
- Is it possible to do this connection between SF and Marketing Cloud REST API using these features? (Named Credentials, Auth Providers and Custom Metadata Types).
- If so, do you have any documentation I can read with an example of how to do it? I have read the SF help documentation and I couldn’t find anything.

Thanks in advance!!

Regards,
Darcy Rippon 7Darcy Rippon 7
I'm also having this issue in an attemp to delete a contact from MC when a contact / Lead is merged or deleted in Salesforce.  Do you have any further insight??
Deepak Hanumantha AndeliDeepak Hanumantha Andeli
It is possible with the help of 'Allow Merge Fields in HTTP body' setting on the Named credentials.

Here (https://deepakoncrm.blogspot.com/2019/01/connect-to-marketing-cloud-through.html) are the details steps (https://deepakoncrm.blogspot.com/2019/01/connect-to-marketing-cloud-through.html)
Bang BullBang Bull
Oleg Gorbach 13Oleg Gorbach 13

Update, I have the same issue. 

All works fine from apex with hardcoded credentials.

How do it all in a safe way using Named Credentials, Auth Providers, and Custom Metadata Types?