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
ayu sharma devayu sharma dev 

Get session Id without using token and Connected app.

Hello,
I am new to salesforce rest and soap api, I am trying to get the session Id from Salesfroce so I can use it for other restservices. I am able to do this using the Soap api but it requires token along with username ana password.
Is there any way I can get session Id only using username and password.
I don't want to create a connected app as my app is for every org, so i get to create it on all the orgs, which certainly I dont want.
Please suggest a Solution.
Raj VakatiRaj Vakati
You can get the session id using UserInfo.getSession() 

Refer below link: -

https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/quickstart_oauth.htm

Also, Use UserInfo.getSessionId() method to get the Login User Session Id.

You can use Password Authentication

https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/intro_understanding_username_password_oauth_flow.htm


 how to get session id without using username and password and security token.
Use UserInfo.getSessionId() method to get the Login User Session-Id.

https://sfdcpanther.wordpress.com/2017/10/02/create-anonymous-salesforce-apex-rest-api-with-force-com-platform/

https://salesforce.stackexchange.com/questions/130138/best-way-to-get-session-id-or-oauth-access-token
 
ayu sharma devayu sharma dev
Hello Raj, thanks for the quick response.
The problem is I am not using the login using the Apex I am building a third party app, So userinfo.getSessionId() won't work for me.
I want get the session Id just like how Dataloader and Visual Studion Code does. Is there any chance I can login like that too.