How to remove Third-Party Account Links in Salesforce?

How to remove Third-Party Account Links in Salesforce?

Following sample Code can be used to remove Third-Party Account Links in Salesforce.

Sample Code:

String authProviderId = '';//Provide the Auth. Provider Id
String strUserId = '';//Provide the User Id

ThirdPartyAccountLink objTPAL = [ 
SELECT RemoteIdentifier 
FROM ThirdPartyAccountLink 
WHERE UserId =: strUserId 
];

//For Facebook use facebook, for Google use google
Boolean checkBool = Auth.AuthToken.revokeAccess( authProviderId, 'open id connect', strUserId, objTPAL.RemoteIdentifier );
system.debug( 'Output Is ' + checkBool );

Leave a Reply