+ Start a Discussion
OlenaOlena 

Error when connecting to Salesforce - Login to login.salesforce.com failed

Hello guys,
I am connecting to Salesforce in Apache NiFi using Reliersoft JDBC driver.
But I cannot connect because of this issue: "Cannot create PoolableConnectionFactory (Login to "login.salesforce.com" failed: Invalid username, password, security token; or user locked out.)".

I created connection string based on their documentation and it looks this way: 
jdbc:sforce://login.salesforce.com?user="my_username"&password="my_password"&token="my_token"&api=50.0
Here is database driver class name: 
com.reliersoft.sforce.jdbc.Driver

Also I tried to use combination password+token but the error remains.
The username, password and token are 100% correct. The user is not locked out.
Moreover, when I am using CData JDBC driver, everything works fine.

Please let me know what else can be an issue except incorrect username/password/token?
Best Answer chosen by Olena
GauravendraGauravendra


Hi Olena,

Lets do few things. I believe user is got locked out.
  • Check the user is locked or not. If locked, unlock it and reset the password. [Unlock User (https://help.salesforce.com/articleView?id=sf.users_unlock.htm&type=5)]
  • If User is not locked, then also reset the password. Then try again.
  • Decrease the api level in the request. &api=47
  • Change the password policy of org. Maximum invalid login attemps : No Limit (as of Now).
Hope this helps!

All Answers

GauravendraGauravendra
Hi Olena,
  • Make sure you are connecting to prod instance rather than sandbox cause that will change the url to test.salesforce.com
  • Can you try with SecurityToken inplace of just token.

Hope this helps!
OlenaOlena

Hi Gauravendra, thanks for the answer!

Unfortunately it didn't help - the same error is when I am using SecurityToken and I am connecting to the prod instance

OlenaOlena
Update: just want to add that there are no special characters neither in password, nor in security token.
GauravendraGauravendra

Hi Olena,
  • Can you try logging through UI using same username and password and see if you are getting the same error or not.
  • Try resetting the security token.
  • Check this user login history, and see if you getting the Failed request there. Check the error there as well.
  • Can you try decreasing the api level. This could be causing due to latest api version.

I found this regarding api:
api
Note, API versions much younger or older than the driver release date, may not be compatible with the driver. To resolve this, check the website for a new version of the driver. The current driver version can be found with getDriverVersion().
The default API version may change with newer releases of the driver. To check the API endpoint version being used, refer to getDatabaseProductVersion().

Hope this helps!
OlenaOlena
Hello Gauravendra, thanks!

Can you try logging through UI using same username and password and see if you are getting the same error or not.
  • Yes, I can log in to Salesforce successfully
Try resetting the security token.
  • Unfortunately it didn't help, I tried this
Check this user login history, and see if you getting the Failed request there. Check the error there as well.
  • I can see that the error is 'Invalid password' and then 'Password lockout'. But the password is 100% correct
Can you try decreasing the api level. This could be causing due to latest api version.
  • I think it really can be an issue as drivers may need to use lower versions of API. But it is strange that there is no error about API version mismatch but the error with invalid password. 
Gauravendra, please let me know if there is a way to decrease API version in Salesforce?

Thanks for the answer!
GauravendraGauravendra


Hi Olena,

Lets do few things. I believe user is got locked out.
  • Check the user is locked or not. If locked, unlock it and reset the password. [Unlock User (https://help.salesforce.com/articleView?id=sf.users_unlock.htm&type=5)]
  • If User is not locked, then also reset the password. Then try again.
  • Decrease the api level in the request. &api=47
  • Change the password policy of org. Maximum invalid login attemps : No Limit (as of Now).
Hope this helps!
This was selected as the best answer
OlenaOlena

Hello Gauravendra,

Thanks a lot! And sorry for the late answer.

It turned out that the API version was incompitable with Salesforce JDBC drivers and I am using Salesforce REST API instead to get and insert data.

Thanks for the help.