Posts

Showing posts with the label Login

Authenticate using the SOAP login request

Login using the SOAP login request and from then on use the session token for making REST API requests.In this we need to pass Username and Password as credentials.Upon invocation, the API authenticates the credentials . It then returns the  sessionId , the user ID associated with the logged-in username, and a URL that points to the Lightning Platform API to use in all subsequent API calls.If Salesforce returns a Login fault , try adding the security token at the end of the user’s password.  The limit is 3,600 calls to login() per user per hour. Exceeding this limit results in a “Login Rate Exceeded” error. After reaching the hourly limit, Salesforce blocks the user from logging in. Users can try to log in again an hour after the block occurred. Sample Code -             HTTPRequest request = new HTTPRequest();             String username = 'rpatnaik@docmation.com';            ...

Validate Salesforce User

Image
 Here's a piece of code to verify the password of a user.            HttpRequest request = new HttpRequest();         request.setEndpoint('https://login.salesforce.com/services/Soap/u/22.0');         request.setMethod('POST');         request.setHeader('Content-Type', 'text/xml;charset=UTF-8');         request.setHeader('SOAPAction', '""');         request.setBody( prepareSoapLoginRequest ('me_raja1@test.com','QW@232323'));         ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info, String.valueOf(new Http().send(request).getBody())));  public static String  prepareSoapLoginRequest (String username, String password){         XmlStreamWriter w = new XmlStreamWriter();         w.writeStartElement('', 'login', 'urn:partner.soap.sforce.com');         w.w...