Authentications within Salesforce could be quite hard, especially if it calls for coding modifications. Parameters for authenticating Apex callouts often need changes in code. But Salesforce came up with a solution to simplify authentications set-up through the use of named credentials.
Named Credentials Defined
Named credentials configure both the URLs of the callout endpoints and their equivalent authentication parameters. An Apex callout that uses a named credential as its callout endpoint automatically tells Salesforce to manage its authentication process. Without a named credential, the user otherwise has to input code to facilitate the authentication of said Apex callout.
Authentication Services Supported by Named Credentials
Using named credentials in the following authentications are allowed:
- Password/Basic Authentication
- OAuth 2.0
Anonymous Web Service callouts also support Named Credentials.
Why Use Named Credentials?
Named credentials boost Salesforce productivity and simplify process for Apex callouts. Aside from that, here are specific reasons why developers should switch to using named credentials:
- A Single Place for Storing User Credentials
Developers used to store their personal user credentials in various Salesforce elements. They use custom settings, metadata, and objects for this. There is no uniform method to store credentials, thus, presenting various problems during user credential use. Maintaining the credentials are especially difficult for admins.
However, with the advent of named credentials, developers finally have a place to store their credentials. Admins have easier control and maintenance of the credentials, because they’re all found within the org’s Salesforce Setup. No need to search through various elements in Salesforce.
- Automated Salesforce Authentication
Isn’t it great when Salesforce handles all authentication services by itself? With named credentials, this is possible. Named credentials eliminates the need for developers to code for facilitating authentication processes. While codes for basic authentications are simple enough, codes for OAuth aren’t. So it’s a sound decision to switch to named credentials for faster Apex callout authentication.