+ Start a Discussion
Ashish MalikarAshish Malikar 

Want to logged-in as another user in apex

Hi All,

I want to logged-in as another user to execute some part of code, like in test classes we can use System.runAs(). But this is not applicable in non-test context. Is there another alternative to do this in non-test apex class?

Arpit Jain7Arpit Jain7
Since Apex code runs as System Admin, I am not sure you will need to login as another user. But still if you want this you can use Rest API/SOAP API to achieve the same. Below is one of the example how to do the same with Rest API



Please mark this answer as SOLVED and BEST ANSWER if it helps you.