richard_griffit
5 years agoNew Contributor
Get Snap Task 401 (Unauthorized) Error
Hi,
Hoping someone can offer some advice around this for me.
Problem: I have a snap pipeline set up as a task in our environment, when called with a param it will return some json data around customer information. I can test this via postman with cloud and locally on my machine with the browser using both urls (on prem and cloud). However when using my web application (React) and using fetch() - I’m getting the 401 (Unauthorized) error in the console.
Should i be using Basic Auth or the Bearer Token?
Both of which seemed to be failing and nothing under in the headers (inspected the network tab in dev tools)
Preview of my code making the request
fetch(url, {
mode: 'no-cors',
headers: new Headers({
"Authorization": `Basic ${base64.encode(`${login}:${password}`)}`
}),
})
Any help would be greatly appreciated thanks.
Regards
Rich