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
Josh Harrison 7Josh Harrison 7 

Provisioning auth provider and/or named credential through code

Hi, I'm very new to Salesforce development. I'm looking for a way to provision auth providers and named credentials through code. I originally posted my question on the general helps site: https://success.salesforce.com/answers?id=9063A000000iiVd. Anything to point me in the right direction, or alternative solution recommendations, would be much appreciated. Thanks.
Harish DHarish D
Hi Josh,

Here is the snippet where I am refering End Point from NamedCredentilas. In this example "ProjectService" is my NamedCredential name.

HttpRequest req = new HttpRequest();
req.setEndpoint('callout:ProjectService'); 

When using Named Credentials you can give the Authentications details in the Named Credentials it self, and make sure to check 
"Generate Authorization Header".
Thanks,
Harish