I have a requirement where I need to access some services of my Salesforce Org2 from Salesforce Org1. Now this can be done using OAuth2.0 and also by using PartnerWSDL class (both tried and working fine). Also I am trying to use basic password based user authentication in Org2 by calling from Org1; the login is successful with Status Code=200 but I am not getting any session_ID/Access Token in response. Is it possible to get session_ID or Access_Token using password based authorization? Below is my code snippet, please let me know your thoughts.

    String EndPointurl = 'https://login.salesforce.com'; 
    HttpRequest req = new HttpRequest();

    String USERNAME = '[email protected]';
    String PASSWORD = 'password+SecToken';

    Blob headerValue = Blob.valueOf(USERNAME + ':' + PASSWORD);
    String authorizationHeader = 'BASIC ' +
    req.setHeader('Authorization', authorizationHeader);

    Http http = new Http();
    HttpResponse response = http.send(req);
    System.debug('REST response is :: '+response); 
    System.debug('REST response body is :: '+response.getBody());

1 Answer 1


Basic HTTP Authentication is not supported by Salesforce. You must use OAuth, SOAP, SAML, or JWT authentication. Note that Basic Authentication doesn't provide a session id by definition of that authentication scheme. There are no services that use Basic Authentication in this manner, since it would not be compliant with the standard.

  • Thank you @sfdcfox
    – HRZ
    May 20, 2019 at 16:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .