Forum Discussion
Have you checked out the documentation on Triggered Pipeline Access Control? Let us know if there are gaps or more details that we could provide.
- mbowen5 years agoEmployee
Hi Rich:
You should be passing the generated bearer token for the task. Something like
Authorization: Bearer 9V9HGRt0m9BRgD42AZWpzC14QuYABCDE
Is this a triggered or Ultra task ?
- richard_griffit5 years agoNew Contributor
I had also tried that approach passing the
"Authorization" : "Bearer {token_value}"
But still receiving a 401. I did notice that the browser asked for my credentials where as postman didn’t. Hence why i tested with basic.
I am using a triggered task, unfortunately I’m not clued up on the Ultra Tasks - is this something i should be using in this scenario?
Thanks for your response
Regards
Rich- mbowen5 years agoEmployee
Hi Rich:
A triggered task should be fine for what you’re doing. An Ultra pipeline/task runs constantly and is meant for real-time processing. You can read more about it here.
https://docs-snaplogic.atlassian.net/wiki/spaces/SD/pages/1438189/Triggered+Tasks
If you don’t supply a bearer token, then you need to supply your SnapLogic credentials. It sounds like neither is working you (that is, you’re getting a 401).
I’ve verified a simple triggered task using Curl and also a Java client. I assume the bearer token is valid and you have verified the authorization header is written into the request for your React app.
Here is curl request with a valid bearer token:
$ curl -verbose -X POST \ -H "Authorization: Bearer T3gwZuqhcc1no4ZBltrZi4XVTqiPwfdP" \ -H "Content-Type: application/json" \ -d '{"param1": "value"}' \ http://sm-mbp-mbowen:8888/api/1/rest/slsched/feed/snaplogic/projects/support/simple-task-1 REQUEST: > POST /api/1/rest/slsched/feed/snaplogic/projects/support/simple-task-1 HTTP/1.1 > Host: sm-mbp-mbowen:8888 > User-Agent: curl/7.54.0 > Accept: */* > Referer: rbose > Authorization: Bearer T3gwZuqhcc1no4ZBltrZi4XVTqiPwfdP > Content-Type: application/json > Content-Length: 19 RESPONSE: < HTTP/1.1 200 OK ... [ {"content":{"param1":"value"}} ]
A curl request with my SnapLogic credentials:
$ curl --user mbowen@snaplogic.com:<password> -verbose -X POST \ -H "Content-Type: application/json" \ -d '{"param1": "value"}' \ http://sm-mbp-mbowen:8888/api/1/rest/slsched/feed/snaplogic/projects/support/simple-task-1 REQUEST: > POST /api/1/rest/slsched/feed/snaplogic/projects/support/simple-task-1 HTTP/1.1 > Host: sm-mbp-mbowen:8888 > Authorization: Basic YWRtaW5Ac25hcGxvZ2ljLmNvbTpBZG0xbkAxMno= > User-Agent: curl/7.54.0 > Accept: */* > Referer: rbose > Content-Type: application/json > Content-Length: 19 RESPONSE: < HTTP/1.1 200 OK ... [ {"content":{"param1":"value"}} ]
I will get a 401 if either the token or credentials aren’t valid.
< HTTP/1.1 401 UNAUTHORIZED {"response_map": {"error_list": [{"message": "Authentication required"}]}, "http_status_code": 401}
It sounds like you are able to trigger the task via Postman, so you’re passing the right authentication bits. Is your browser configured to use a proxy? Seems something with the React app.