'An Authentication object was not found in the SecurityContext, an error with fetch request
I'm trying to call to an API endpoint using cURL and fetch(JavaScript), as it works fine with cURL where it's equal fetch doesn't.
Here is the cURL request:
curl -i -L -H 'Accept: application/json' --data 'client_id=[ID]&c
lient_secret=[SECRET]&grant_type=authorization_code&red
irect_uri=[REDIRECT_URI]&code=[CODE]' https://orcid.org/oauth/token
Where fetch:
fetch("https://orcid.org/oauth/token", {
method: "POST",
headers: {
Accept: "application/json",
},
body: `client_id=[ID]&c
lient_secret=[SECRET]&grant_type=authorization_code&red
irect_uri=[REDIRECT_URI]&code=[CODE]`,
})
.then((res) => res.json())
.then((data) => {
console.log(data);
})
.catch((error) => console.log(error));
ERROR:
www-authenticate: Bearer realm="orcid", error="unauthorized", error_description="An Authentication object was not found in the SecurityContext"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
