You need to sign in to do that
Don't have an account?
Issues connecting with the Partner WSDL
Right now I'm just trying to establish a connection between my java app and Salesforce, but it isn't working out very well. For some reason on my connection = new PartnerConnection(config); line I always error.
[ApiFault exceptionCode='INVALID_LOGIN' exceptionMessage='Invalid username, password, security token; or user locked out.'
I have already confirmed that my username/password/security token are all correct.
public static void main(String[] args) {
ConnectorConfig config = new ConnectorConfig();
config.setUsername("MYLOGIN");
config.setPassword("MYPW&MYTOKEN");
PartnerConnection connection;
try {
connection = Connector.newConnection(config);
} catch (ConnectionException e) {
// TODO Auto-generated catch block e.printStackTrace(); } }
I figured it out... something dumb of course. I had to remove the ampersand from my password section.
config.setPassword("MYPW&MYTOKEN");
to
config.setPassword("MYPWMYTOKEN");
All Answers
Please set config.setPassword ("mypassword") only ...no token. Make sure the user is not locked out by web login at http://login.salesforce.com. Once your'e sure you're not locked out, you can try as I said.
I already tried this, it then told me that I need a security token in the error log.
I think you're not setting the auth endpoint. This is what I use normally:. I define the endPoint, userName, Password in a property file and pass them to this method. See if it works for you.
private ConnectorConfig createConnectionConfig(String endPoint, String userName, String password) throws ConnectionException {
ConnectorConfig connectionConfig = new ConnectorConfig();
if ( endPoint != null && userName != null && password != null ){
connectionConfig.setServiceEndpoint(endPoint);
connectionConfig.setAuthEndpoint(endPoint);
connectionConfig.setUsername(userName);
connectionConfig.setPassword(password);
return connectionConfig;
}
}
Well, maybe my endpoint isn't correct. How do I determine what this should be? From what I've read, if its blank it should be able to figure it out anyways. I've seen a couple of things that looked about right, but when I used them it didn't work out either.
Is it prod or sandbox env ? Do you normally login using web at login.salesforce.com ?
If you're using API, it should be of the form endpoint = https://login.salesforce.com/services/Soap/u/22.0 (the version can vary). if you're using sandbox env. use https://test.salesforce.com/services/Soap/u/22.0.
I'm assuming you're using partner wsdl for connection. If you're using enterprise the endpoint varies.
It errored, but told me I had to have hte endpoint as servers/Soap/c/22.0 instead of the 'u'. After making that change, I also removed the security token and got the error:
[LoginFault [ApiFault exceptionCode='LOGIN_MUST_USE_SECURITY_TOKEN' exceptionMessage='Invalid username, password, security token; or user locked out. Are you at a new location? When accessing Salesforce--either via a desktop client or the API--from outside of your company’s trusted networks, you must add a security token to your password to log in. To receive a new security token, log in to salesforce.com at http://login.salesforce.com and click Setup | My Personal Information | Reset Security Token.']
Then after that I put the security token back in:
[LoginFault [ApiFault exceptionCode='INVALID_LOGIN' exceptionMessage='Invalid username, password, security token; or user locked out.']]
This exact same info works when I'm trying to bring the instance into Eclipse (I'm doing this on a Developer org btw).
Nevermind... I think the /c/ was the instance of hte project I was testing using another way to login. My partner login I used the /u/ and got the same issues.
u indicates you're using enterprise wsdl to connect to salesforce. Based on the error, I think the endpoint is wrong. You're getting the security token from a prod instance (by logging in at login.salesforce.com) and trying to use that security token with a dev org (which cannot validate that token).
1) Try to login to test.salesforce.com instead of login.salesforce.com and get the security token.
You can use this link http://success.salesforce.com/apex/questiondetail?qId=a1X30000000HxnYEAS for reference.
Yea, I had a couple of different projects trying to get any of the enterprise/partner working. I looked at the wrong one there. I am using a Developer org though and not a Sandbox so the login.salesforce is correct.
I figured it out... something dumb of course. I had to remove the ampersand from my password section.
config.setPassword("MYPW&MYTOKEN");
to
config.setPassword("MYPWMYTOKEN");
Is there any solution to avoid the security token. I don't want to use the security token, because if the password is being changed again i have to get that newly generated security token from the mail id of the user.