Hey there….
Today it’s about Named Credentials in salesforce. How you can use it and when you can use them. A quick guide to help you start up. Wanted to write about it many times but not sure why kept delaying it. But any way the time has come to write about it. There is someone, who must be happy about this article ☺. Hope you get it .
What it is ?
This is a configuration in salesforce, that takes care of some or most part of the authentication in an integration. This integration can be within the same salesforce org or with another salesforce org or any other webservice vendor. As it’s configuration it’s easy to setup and maintain.
By using named Credentials you don’t have to worry about changes in the end point URL or parameters. You may think we can still do it with custom settings or custom meta data etc. Yes, you are correct, but then you have to write codes to do the authentication. To avoid that you can try named Credentials.
When to use it ?
As I already said, you can use it in various scenarios such as : integration within the same salesforce org or any other salesforce org (kind of salesforce to salesforce ) or any other webservice vendor.
What is the benefit?
This saves a major part of authentication code. If you see the below two samples, you will notice the difference in coding. The image 1 the end point is hard coded and cannot be changes. If we want to change this end point , we will have to make the code change or make something that will use custom setting. You can see the image 1.1 , for the out put this code will give. But see the image 2, this is something different and instead of endpoint link we have a “Name” there. This is the Named Credential. This is kind of Custom Setting but it does more than that. Will explain in a little while. You can also see the out put of the code which used Named Credential in image 2.1.
Steps for you :
In your salesforce setup quick find type : Named Credentials
You can fill in the information such as the endpoint and authentication mode.
Label:
You can give any name you like
Name
: Will be kind of API name
Certificate
:If you provide a certificate in the certificate field, then this certificate will be used for authentication in every 2 way SSL (TLS) authentication with external system.
Identity type
can various types. Such as :
- Anonymous: No identity and therefore no authentication. (As shown on the above example)
- Per User: Use separate credentials for each user who accesses the external system via callouts. Select this option if the external system restricts access on a per-user basis.
After you grant user access through permission sets or profiles in Salesforce, users can manage their own authentication settings for external systems in their personal settings.
-
Named Principal:
Use the same set of credentials for all users who access the external system from your organization. Select this option if you designate one user account on the external system for all your Salesforce org users.
Authentication Protocol:
This can be 2 types :
Where you will enter the user name and password to be used in the integration.
OAuth 2.0 :
Where you will follow the OAuth details such as authentication provider, scope of the permission to request for an access token. Refer OAuth site for more info on this protocol.
Conclusion:
For this post I kept it very simple and wanted to just give an glimpse of the feature. In next post I will explain more in details with example where, we will discuss about the authentication methods in little more details.
Hope this helps to start something….will get an integration done in the next post. Till then keep reading and sharing……
Love to hear your thoughts, questions and comments.
Leave a Reply