Salesforce API Login Authentication

package com.thysmichels;
import com.sforce.soap.enterprise.Connector;
import com.sforce.soap.enterprise.EnterpriseConnection;
import com.sforce.soap.partner.*;

public class SalesforceLogin {

	 * @param args

	public static void main(String[] args) {
		// TODO Auto-generated method stub
			BufferedReader reader = new BufferedReader(new InputStreamReader(;
			System.out.println("Enter Salesforce Username: ");
			String username = reader.readLine();
			System.out.println("Enter Salesforce Password: ");
			String password = reader.readLine();
			System.out.println("Enter Salesforce Security Token: ");
			String sectoken = reader.readLine();
			if (SFLogin(username, password, sectoken) == true)
				System.out.println("*** Login Success ***");
				System.out.println("*** Login Failure ***");
		catch (IOException e) {
		// TODO Auto-generated catch block
	public static boolean SFLogin(String username, String password, String sectoken)
		try {
			ConnectorConfig sfconfig = new ConnectorConfig();
			//Use your salesforce username = email
		    //Use your saleforce password with your security token look like: passwordjeIzBAQKkR6FBW8bw5HbVkkkk
		    sfconfig.setPassword(password + sectoken);
		    EnterpriseConnection entercon = null;
		    entercon = new EnterpriseConnection(sfconfig);
		    if (entercon.login(username, password + sectoken).isPasswordExpired()== false)
		    	System.out.println("SessionID: " + sfconfig.getSessionId());
		    	System.out.println("Auth End Point: " + sfconfig.getAuthEndpoint());
		    	System.out.println("Service End Point: " + sfconfig.getServiceEndpoint());
		    	return true;
		    	return false;
		   catch (ConnectionException ce) {

			      return false;


SessionID: 00DA0000000ao2F!ASAAQK5JbvhkfzbsYOG7_c9XFKauUzzw9HjB8IJ8r9W54IapCOmQk8AdK59u_O.Izd2hDtyXCDqbltlryV.MI3DKSagoIiUR
Auth End Point:
Service End Point:
*** Login Success ***

4 Comments on “Salesforce API Login Authentication

  1. I getting error at import com.sforce.soap.enterprise
    Where to get jar file. I am not able to find exactly

  2. If you are interested in topic: can you make money
    growing vegetables – you should read about Bucksflooder first

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: