Ask Your Question

Retrieving a bearer token from Salesforce

asked 2020-04-23 12:20:38 -0500

oberfirer gravatar image

updated 2020-04-23 21:03:23 -0500

metadaddy gravatar image

Hello, I'm running a local install of SDC 3.8.0 and trying to retrieve a bearer token from Salesforce using a connected app client ID and client secret using HTTP processor.I intend to use it in a subsequent call to a Salesforce-hosted rest web service. I tried using OAuth on the HTTP processor without much success, so I decided to break that into 2 parts - get a bearer token first, then pass it to the next stage as a header attribute. I keep getting a bad request 400 errors with the following configuration on the HTTP processor (I can't seem to upload an screenshot, so writing up the parameters):

Output Field: /test
Resource URL:
Headers: Content-type : application/x-www-form-urlencoded
HTTP Method: Post
Request Data:  
Default Request Content Type: application/x-www-form-urlencoded
Authentication Type: None

The same setup works in Postman and retrieves the token. I also tried using a Streamsets Shell component to execute CURL with the same params, and that works as well as follows:

curl -v -d "grant_type=password" -d "client_id=fake_client_id" -d "client_secret=fake_client_secret" -d "username=user@sf@com" -d "password=fake_password" |  jq -r ".access_token" > test_sf_token.txt

I just can't get it to work in the HTTP processor, which I believe would be most appropriate for the use case. Any pointers would be appreciated.

Thank you! Oleg

edit retag flag offensive close merge delete


Hey Oleg - long time no see. I upvoted your post so you'll have enough reputation to add an image.

metadaddy gravatar imagemetadaddy ( 2020-04-23 21:02:41 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2020-04-23 21:07:46 -0500

metadaddy gravatar image

The content type is application/x-www-form-urlencoded, so you need to format the request data like the body of an HTTP POST, rather than as JSON:


A great way to test stuff like this is to use a Request Bin as the end point so you can see exactly what the HTTP Client processor is posting compared to curl.

edit flag offensive delete link more

answered 2020-04-23 22:39:34 -0500

oberfirer gravatar image

Thanks, Pat, that worked! Also, thank you for the Request Bin pointer. Have not used it before, but wI see how it can be useful. Hope all is well. Regards, Oleg

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2020-04-23 12:20:38 -0500

Seen: 49 times

Last updated: Apr 23