Etsy API Authentication Problem

HI everybody :slight_smile: I’m a newbie and I’m trying to connect my API following the tutorial Quick Start Tutorial | Etsy Open API v3 provided on the Etsy website. The problem is I’m getting stuck at this part of the code
const response = await fetch(tokenUrl, requestOptions);
// Extract the access token from the response access_token data field
if (response.ok) {
const tokenData = await response.json();
res.send(tokenData);
} else {
res.send(“oops”);
}
});

After trying a bit I noticed that the token url ‘https://api.etsy.com/v3/public/oauth/token’ is throwing a 400 error but I can’t find a way to make it work . I tried contacting them directly but no response. Any help appreciated. Thanks.

I’ve only used the listings endpoint which does not require authentication (other than an API key). Are you able to get an unauthenticated endpoint like that to work?

Just perusing the link you provided, the first things I’d look at are the options you pass into the fetch request. Are you sure you’re using the correct values?

It might also be worth noting that it doesn’t look like https://api.etsy.com/v3/public/oauth/token URL is meant to serve GET requests, so you can’t navigate to it in your browser.

Finally, are you sure you need to authenticate? Are you building something that needs a user to login, or can you get away with using unauthenticated endpoints? What’s your end goal?

Hi @Kevin thanks for replying. The final goal is to get the user to login that’s why I need to authenticate first. I’m just following the tutorial but can’t manage. To be honest I haven’t given it too much attention but even tried to contact them but still no reply

If I were you, I’d try to figure out where your code is failing. What is the response in your code? Can you get to any error messages?

Yes its the part I posted in the first response here that is failing.

Right, but the next step is to figure out how it’s failing. Right now you’re only printing out “oops” if it fails. Is there a way to print out more information about why it failed? I’m not super familiar with node, but I know if you were running this in the browser you could check the network tab to examine the request and response. Does your environment have something similar you could look into, or does the response variable maybe contain any helpful fields or functions for getting that information?