0
votes

I am trying to run a simple example to authenticate with Salesforce using a Java code.

I am getting below error - 400 Bad Request

The login URL which I am using is

https://login.salesforce.com/services/oauth2/token?grant_type=password&client_id=clienty_id&client_secret=client_secret&username=username&password=password

I also tried removing the amp and ;

https://login.salesforce.com/services/oauth2/token?grant_type=password&client_id=clienty_id&client_secret=client_secret&username=username&password=password

But still got the same error 400 bad request.

1
remember to use POST, remember to URLEncode the parameter values. If you're still having problems, post your code.superfell

1 Answers

1
votes

You need to try this call with a "POST" callout. When you use the "GET" method, you get the 400 bad request issue. or You missed appending security token at the end of the password

https://login.salesforce.com/services/oauth2/token?grant_type=password&client_id={clientId}&client_secret={client_secret}&username={userName}&password={password}{securitytoken}

Method : POST