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

Highlighted
Four Stars

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.

 

 

 

 

Highlighted
Four Stars

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

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)

 

 

Highlighted
Five Stars

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

Do you have a connected app in Salesforce ?
Highlighted
Four Stars

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

@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.

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog