Greetings,
My problem currently, that I followed specifically what on the Dashbaord is writing to acquire an access token. I even changed my application from Regular Web to Machine-To-Machine application, but even after successfully retreiving the access token with axios, i can’t get anything from the Management API through anpther axios call.
I always get 401 error.
I repeat, I acquire the accesstoken succefully.
Here’s the code for the second API call:
"use server";
import axios from "axios";
import GetAccessToken from "./GetAccessToken";
export default async function fetchApiData() {
try {
const token = await GetAccessToken();
console.log(token);
const options = {
method: "GET",
url: "https://REDACTED.auth0.com/api/v2/users-by-email",
params: { email: "{REDACTED EMAIL ADDRESS}" },
headers: {
"content-type": "application/json",
authorization: `Bearer ${token}`,
},
};
await axios(options).then((response) => console.log(response.data));
} catch (error) {
console.error("Error fetching API data:", error);
}
}