How to login to salesforce using session id?

|
| By Webner

We may also access Salesforce without having to enter a username and password. We may log into Salesforce using the session ID.

To log in to salesforce using session-id follow the following steps:

Step 1: execute this piece of code in the “Anonymous window” of the developer console

String sessionID=UserInfo.getOrganizationId()+''+UserInfo.getSessionId().subString(15);
system.debug('session id '+sessionID);

Salesforce
After this, you will get the sessionId now copy the sessionId
apex-code1
Step 2: in the below URL paste the copied sessionId instead of
https://<endpoint host>/secur/frontdoor.jsp?sid=<session id>”
Example:
https://<endpoint
host>/secur/frontdoor.jsp?sid=00D5g000002y3kOEAQ!AQQAQBr4DvyIIXPQ179oLbO2YbSNVaM5gwogGUEjH3KySqiB5d_9AMmnBwIKhOeekpm5hrXAawl573k4gfQ8mxlD1rb03xoO

Step 3:- in below URL paste the login URL instead of <endpoint host>
https://<endpoint host>/secur/frontdoor.jsp?sid=<session id>”

apex-code2
Copy the highlighted link and paste it instead of “<endpoint host>”

Example: https://webnersolutionsprivatelimi2-dev-ed.my.salesforce.com//secur/frontdoor.jsp?sid=00D5g000002y3kOEAQ!AQQAQBr4DvyIIXPQ179oLbO2YbSNVaM5gwogGUEjH3KySqiB5d_9AMmnBwIKhOeekpm5hrXAawl573k4gfQ8mxlD1rb03xoO

Now using this URL you can log in to sales force in any other system without using a username and password

Leave a Reply

Your email address will not be published. Required fields are marked *