Skip to main content Join us at TDX in San Francisco or on Salesforce+ on March 5-6 for the Developer Conference for the AI Agent Era. Register now.

Hi,

I am trying to implement MFA for community users with apex so that when they log in some users will need to use the Salesforce Authenticator app to complete the login

I am 1st trying to make the user register with the authenticator app

UserManagement.registerVerificationMethod(Auth.VerificationMethod.SALESFORCE_AUTHENTICATOR, '/');

but I get:

11:43:03.4 (187484011)|EXCEPTION_THROWN|[17]|System.NoAccessException: Insufficient Privileges: You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary.  

 

It seems it returns a page reference with sys admin context but not in community user context

Also when I query TwoFactorMethodsInfo I get

sObject type 'TwoFactorMethodsInfo' is not supported

 

What am I missing, the MFA is not enabled at all ?

I also tried registering SMS and EMAIL as a verification method, those return a page reference (it seems to verify the email/phone number) but when I redirect to the page I get 302 and get redirected to the same page I came from

10 comments
  1. Feb 10, 5:41 PM

    Hey @Jani Ruohomaa

     

    Were you able to implement this? I am trying to implement this currently similar to this. I am using flow from this example :

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

     

     

    However, I am unable to access the TwofactorInfo object from the flow even I have given myself the "Manage Multi-Factor Authentication in API" permission. Is there anything other than this that I am missing? 

     

    Thanks, 

    Venky

0/9000