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
This commit is contained in:
@ -35,9 +35,9 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
// 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<Server> {
|
||||
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<Server> {
|
||||
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 || ""
|
||||
}
|
||||
|
Reference in New Issue
Block a user