Thomas
Thomas7mo ago

OAuth 2.0 access

Hi I want to use the etsy api via Buildship and I am having troubles recreating a simple api key test in BuildShip: https://developers.etsy.com/documentation/tutorials/quickstart So they create a a valid OAuth 2.0 access token to make requests to any scoped endpoint. Is there any tutorial or resource on OAuth 2.0 access with BuildShip ?
Quick Start Tutorial | Etsy Open API v3
This tutorial walks you through building a very simple Node.js application from start to finish. By the end, you will have a working application with a valid OAuth 2.0 access token to make requests to any scoped endpoint.
Solution:
Hey @Thomas, to make an Etsy API Call via BuildShip, all you need to do is make a simple call to the Etsy API endpoint, like this: ```js export default async ({apiKey},{logging}) => { const url = 'https://api.etsy.com/v3/application/openapi-ping';...
Jump to solution
5 Replies
Thomas
ThomasOP7mo ago
This is what I tried (with chatGPT), but I am having troubles form the start with "express": // Import the required libraries const express = require('express'); const fetch = require("node-fetch"); // Initialize a new Express app const app = express(); // Define your Etsy API Key here - replace the placeholder with your actual Etsy API Key const etsyKeystring = 'YOUR_ETSY_API_KEY'; // Define a handler for GET requests on the '/ping' path app.get('/ping', async (req, res) => { // Set up the options for the external API request, using the etsyKeystring for the x-api-key header const requestOptions = { 'method': 'GET', 'headers': { 'x-api-key': etsyKeystring, // Use the etsyKeystring variable }, }; // Attempt to fetch data from Etsy's openapi-ping endpoint try { const response = await fetch('https://api.etsy.com/v3/application/openapi-ping', requestOptions);
// If the request was successful, parse and send back the response data if (response.ok) { const data = await response.json(); res.json(data); // Use json() for proper JSON formatting } else { // If the request failed, send back a simple error message res.status(500).send("API request failed"); } } catch (error) { // Handle any errors that occurred during fetch console.error("Fetch error: ", error); res.status(500).send("Server error"); } }); // Define the port to listen on const port = 3003; // Start listening for requests app.listen(port, () => { console.log(App listening at http://localhost:${port}); });
Harini
Harini7mo ago
cc @Bhavya
Solution
Bhavya
Bhavya7mo ago
Hey @Thomas, to make an Etsy API Call via BuildShip, all you need to do is make a simple call to the Etsy API endpoint, like this:
export default async ({apiKey},{logging}) => {

const url = 'https://api.etsy.com/v3/application/openapi-ping';
const options = {
method: 'GET',
headers: {
"x-api-key": apiKey
}
};
const resp = await fetch(url, options);
const data = await resp.json();
return data;
}
export default async ({apiKey},{logging}) => {

const url = 'https://api.etsy.com/v3/application/openapi-ping';
const options = {
method: 'GET',
headers: {
"x-api-key": apiKey
}
};
const resp = await fetch(url, options);
const data = await resp.json();
return data;
}
Here's a boilerplate node that you can copy and paste in your workflow. You can also use the "Modify Node with Al" feature to modify it according to your use case, learn more. Hope this helps :)
Thomas
ThomasOP7mo ago
@Bhavya that works! Thank you sooo much! That´s amazing 🙂