Client Credential Flow

Client Credentials Flow is simple and easy authentication mechanism which Salesforce has newly introduced in Spring 23. This flow comes handy when you want to connect your app to Salesforce APIs outside the context of any particular user

What does the Client Credential Flow brings to the table?

- Consumer key and secret becomes the client credentials
- Eliminates the need for explicit user credential sharing
- More secure alternative to the OAuth 2.0 username password flow


How client credential flow is more secure and easy to maintain than username password flow?

There are two primary reasons which makes the client credential flow more secure
1. To get the access token, explicit user credentials are not required thus, encapsulates the user context
2. Client Id and Client Secret are comparatively long and random

As the explicit user context is not known to third party application thus, it makes the integration dynamic and easy to maintain.

Suppose, we have an integration which use username password flow. So, to get access token one has to pass client id, client secret, grant type, username and password. If the user is no longer part of the organization then new user credentials needs to be shared with third party. However, if the integration is using client credentials flow, no explicit user creds are shared and user context can be easily changed from the connected app without impacting the integration.



How to enable Client Credential Flow in org?

1. To use client credentials flow, a connected app is required. In new or existing connected app check the Enable Client Credentials Flow checkbox under API (Enable OAuth Settings)


2. In the connected app policies specify Run As user under Client Credentials Flow section




What can be done if you feel like client key and client secret is compromised?

Connected app provides a way to generate new client id and secret and allows you apply those new credentials to update in connected app.

                             


Thanks for your time to go through the post, hope it helps!

Popular posts from this blog

Create File versions from Apex

Run as different user in Apex

Creating JKS certificate for JWT Bearer flow in Salesforce