Skip to main content
Announcements
A fresh, new look for the Data Integration & Quality forums and navigation! Read more about what's changed.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to get Token from Salesforce (by tRESTClient) in order to use OAuth connection type

Hello,

 

My task is to connect to Salesforce using OAuth connection Type (Basis connection type works fine).

Talend version is v.6.4.

From Salesforce I received: Client Id, Client Secret, Callback URL (host and port), but I assume I also need to have Token (in tSalesforceConnection component I need to give the path of Token File, please see attached tSalesforceConnection.png):

 

I tried to obtain token by tRESTClient component, configured as on attached tRESTClient.png.

I followed instruction from here: http://luan-itworld.blogspot.com/2016/03/access-salesforce-rest-api-from-talend.html 

 

But tRESTClient return error: 

Exception in component tRESTClient_1 (test_OAuth2_sf)
javax.ws.rs.BadRequestException: HTTP 400 Bad Request

 

I verified credentials from Salesforce, they work fine, the link:

https://[...address..].my.salesforce.com/services/oauth2/authorize?response_type=code&redirect_uri=https%3A%2F%2F[...address..].salesforce.com%3A433&client_id=[Client Id received from Salesforce]

works fine in the browser.

 

Could you please tell what I doing wrong? How to get TOKEN from Salesforce?

 

Much obliged for the the answer.

 

 

 

 

Labels (5)
3 Replies
Anonymous
Not applicable
Author

I would like to add some clarifications to tRESTClient configuration attached previously:

I configured the following parameters:

"client_id" = "MyClientId"

"clients_secret" = "MyClientSecret"

"grant_type" = "password"

"username" = "myUser"

"password" = "myPasswordSecurityToken" -- here I put Password concatenated with SecurityToken, as it is advised here: 

https://developer.salesforce.com/forums/?id=906F00000009BZCIA2

 

I verified credentials, they are correct. But still I get the error:

 

Exception in component tRESTClient_1 (test_OAuth2_sf)
javax.ws.rs.BadRequestException: HTTP 400 Bad Request
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.apache.cxf.jaxrs.client.AbstractClient.convertToWebApplicationException(AbstractClient.java:507)
at org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:902)
at org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:863)
at org.apache.cxf.jaxrs.client.WebClient.invoke(WebClient.java:426)
at org.apache.cxf.jaxrs.client.WebClient.post(WebClient.java:456)
at import_account_project.test_oauth2_sf_0_1.test_OAuth2_sf.tRESTClient_1Process(test_OAuth2_sf.java:826)
at import_account_project.test_oauth2_sf_0_1.test_OAuth2_sf.runJobInTOS(test_OAuth2_sf.java:1228)
at import_account_project.test_oauth2_sf_0_1.test_OAuth2_sf.main(test_OAuth2_sf.java:1077)

 

 

vatsal_ras
Contributor

Do you have a connected app in Salesforce ?
Anonymous
Not applicable
Author

@aszczepanska , I am also trying to get access_token using the below link and encountered with '400 Bad Request' error.

Can you please help me if you were able to resolve this error and get access_token from salesforce for oauth2 authentication.