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

Apex -> Login Second User -> Get Session Id

Is there a way to login another user in the apex class, to get the session id of that user. I probably can do it using the soap Login call within apex, passing username and password for the second user, and get the session id. But wondering if there is a shortcut for the same.

Use Case: In our custom customer portal, we are creating the REST api in sf, which will create the portal user using username and password from the regustration form on the portal site. REST api shoud return the session id the new portal user, to directly login him to the portal.
You can try to do Http Call out for OAUTH token in the rest API.

Thansk for the reply, but i duobt it can done for portal users, but just for full sf users.
it seems that is possible.
Ya buts it assumes we are using sf site for the customer portal, but in our case we are building custom customer portal.