function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Mel LisauMel Lisau 

How can i login to Salesforce that has Multi Factor Authentication on API calls?

How can i login to Salesforce that has Multi Factor Authentication on API calls?

I have started using MFA in Salesforce. I can successfully configure the setting "Multi-Factor Authentication for User Interface Logins" and use the Salesforce Authenticator app.

I have now enabled "Multi-Factor Authentication for API Logins", but in my C# app , the user enters Username, Password and Security Token.
The user logs into Salesforce via the following code:
SFService = new SalesForceEnterpriseService.SforceService() { Timeout = 80000, Url = "https://login.salesforce.com/services/Soap/u/52.0"}; LoginResult result = SFService.login(Username, Password + Token);

But now i get the error:
INVALID_LOGIN: Invalid username, password, security token; or user locked out.
But when i uncheck Multi Factor for API calls i can login successfully.

How can i now login a user if MFA for API calls is enabled and will i be able to make other API calls like getting Entity fields ?
 
Best Answer chosen by Mel Lisau
VinayVinay (Salesforce Developers) 
Hi Mel,

Check Multi-Factor Authentication Login Requirements for API Access

https://help.salesforce.com/s/articleView?id=sf.security_require_2fa_api.htm&type=5

Hope above information was helpful.

Please mark as Best Answer so that it can help others in the future.

Thanks,