From 119c3b2f7cc872cba4c0c307cdc3c53093a9a594 Mon Sep 17 00:00:00 2001 From: Magnus-SmariSma <20734986-Magnus-SmariSma@users.noreply.replit.com> Date: Thu, 20 Mar 2025 23:36:10 +0000 Subject: [PATCH] Update IUCN API integration to use v4 and correct token authentication method. Replit-Commit-Author: Agent Replit-Commit-Session-Id: e931b5ab-041b-42e7-baf1-50017869cef6 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/e19c6a51-7e4c-4bb8-a6a6-46dc00f0ec99/9b4142b7-2774-47f3-b952-2a4615adb390.jpg --- server/routes.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/server/routes.ts b/server/routes.ts index 7b4e77c..2843140 100644 --- a/server/routes.ts +++ b/server/routes.ts @@ -35,9 +35,9 @@ export async function registerRoutes(app: Express): Promise { // If IUCN token is provided, try to validate it if (tokenData.iucnToken) { try { - await axios.get("https://apiv4.iucnredlist.org/api/v4/version", { - headers: { - "Authorization": `Bearer ${tokenData.iucnToken}` + await axios.get("https://api.iucnredlist.org/api/v4/information/api_version", { + params: { + token: tokenData.iucnToken } }); iucnValid = true; @@ -324,8 +324,8 @@ export async function registerRoutes(app: Express): Promise { try { // Check if the API is working by hitting the version endpoint const response = await axios.get("https://api.iucnredlist.org/api/v4/information/api_version", { - headers: { - "Authorization": `Bearer ${iucnToken}` + params: { + token: iucnToken } }); @@ -401,10 +401,8 @@ export async function registerRoutes(app: Express): Promise { try { // Use the v4 API with scientific name endpoint const response = await axios.get("https://api.iucnredlist.org/api/v4/taxa/scientific_name", { - headers: { - "Authorization": `Bearer ${iucnToken}` - }, params: { + token: iucnToken, genus_name: genusName, species_name: speciesName || "" }