I am attempting to implement a custom authentication function on an app service. This involves verifying the existence of a user using the Graph API in order to authenticate the client.
Also tried using other dependencies but getting error as below:
Error : Failed to validate token: Not a function: [object Object] await axios({ method: 'GET', url: 'https://graph.microsoft.com/v1.0/me', headers: { Authorization: 'Bearer ' + token, },
Error: Failed to validate token: ‘get’ is not a function await axios.get('https://graph.microsoft.com/v1.0/me', { headers: { Authorization: 'Bearer ' + token } });
Given the snippet that you shared in the original post, it appears that you’re not returning anything from the function. If you want to return the result of the HTTP request, you could do something like the following:
const res = await context.http.get( ... );
const body = JSON.parse(res.body.text());
return body;
You’ll also want to ensure you implement proper error handling (wrap the request in try/catch, check the returned status code, etc.)