Salesforce MFA in simple-salesforce

1.3k views Asked by At

I am currently using the simple-salesforce library to retrieve data from Salesforce, using the token method.

from simple_salesforce import Salesforce

sf = Salesforce(username='[email protected]', password='password', security_token='token')

But Salesforce is requiring the implementation of a Multi-Factor Authentication, is there anyway I can bypass this or use another method?

Here is the link of the actual article: https://help.salesforce.com/articleView?id=000356005&type=1&mode=1

Thanks!

2

There are 2 answers

0
kjay On BEST ANSWER

I have found one solution:

https://github.com/simple-salesforce/simple-salesforce/issues/457

In my case, I was not using an API user account, rather just a normal user account.

1
eyewell On

I think MFA will be required only for users using the standard login - from the Help article mentioned above, it says: "All internal users who log in to Salesforce products* (including partner solutions) through the user interface must use MFA. To ensure that MFA is enabled for all your Salesforce users, you can turn it on directly in your Salesforce products or use your SSO provider's MFA service."

But you are auth'ing via the API, right?

Can you share an error message or screenshot?

Typically API auths happen via a connected app configured in the org, and as I recall, the connected app has a setting requiring MFA ... This help article goes into greater detail about where MFA is required (which login approaches)

Could it be that you are running into the standard user verification challenge whenever salesforce sees an auth for a user from a new network location. You can disable that here by setting an IP address range.