Custom Authentication Provider Plug-in for SSO

Custom Authentication Provider Plug-in for Single Sign On (SSO) 

Create a Custom Authentication Provider Plug-in

Authentication Providers

You can use third-party authentication providers to configure single sign-on (SSO) and access protected third-party data in Salesforce. This SSO solution, known as social sign-on, includes predefined authentication providers for Facebook and Google. Additionally, you can set up an authentication provider for a third party using OpenID Connect or create a custom provider with OAuth 2.0 support. Customize your authentication provider with request parameters after setting it up.

Before you create your Apex class, you create a custom metadata type record for your authentication provider. For details, see Create a Custom External Authentication Provider.


Assuming you already have Client ID , Client Secret , Scope , Access Token , Authorization and User Infor URL.

Step 1 - Created a Custom Meta-Data to hold Endpoints and Authentication Details














Object and Data Types























Step 2 - Created a global class named B2BTIDAuthPlugin which is extending the Auth.AuthProviderPluginClass in which I have implemented 4 methods:-


global String getCustomMetadataType()

global PageReference initiate(Map<String,String> authProviderConfiguration, String stateToPropagate)

global Auth.AuthProviderTokenResponse handleCallback(Map<String, String> authProviderConfiguration, Auth.AuthProviderCallbackState state)

global Auth.UserData getUserInfo(Map<String, String> authProviderConfiguration, Auth.AuthProviderTokenResponse response)

Step 3 -

Follow the below steps to setup a custom Auth Provider:

Go to Setup → Identity → Auth. Providers

Click on New to create a new Auth Provider

For the provider type, select your custom authentication provider “B2BTIDAuthPlugin“






















































Add the Access Token URL to remote site settings











Comments

Popular posts from this blog

Agentforce in Production: What Separates a Successful Deployment from an AI Demo

Introduction to Salesforce Agent Script: Build Predictable AI Agents

Salesforce Data Graphs - Best Practices, Limits & Guardrails — 2026 Edition