Finished refresh/user token auth flow

This commit is contained in:
2024-03-23 23:47:46 -05:00
parent 6dddc5799f
commit 461b311347
7 changed files with 110 additions and 146 deletions

View File

@@ -1,7 +1,7 @@
// Need to figoure out expiration and make sure to cycle this appropriately to avoid unnecessary calls
import fetch from "node-fetch";
const fetchEbayReadToken = async () => {
const fetchEbayToken = async () => {
const ebayClientId = process.env.EBAY_CLIENT_ID;
const ebayClientSecret = process.env.EBAY_CLIENT_SECRET;
const credentials = Buffer.from(
@@ -15,7 +15,7 @@ const fetchEbayReadToken = async () => {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
Authorization: `Basic ${credentials}`,
"authorization": `Basic ${credentials}`,
},
body: "grant_type=client_credentials&scope=https%3A%2F%2Fapi.ebay.com%2Foauth%2Fapi_scope",
}
@@ -29,6 +29,7 @@ const fetchEbayReadToken = async () => {
}
const data = await response.json();
return data.access_token;
} catch (error) {
console.error("Error fetching eBay OAuth token:", error);
@@ -36,4 +37,4 @@ const fetchEbayReadToken = async () => {
}
};
export default fetchEbayReadToken;
export default fetchEbayToken;