An unexpected error occurred while trying to access the graph.microsoft.com/v1.0/me/manager

Having trouble with my code, can someone help me out? I need to fetch the user's manager from , but the request keeps failing. However, when I run the query , everything works fine. Any ideas on how to fix the issue and make the request for a manager successful?

fastify.post('/login', {
    preHandler: (request, _, next) => {
      if (!request.body || !request.body.username || !request.body.password) {
        const error = new Error('Credentials are missing');
        error.statusCode = 400;

        return next(error);
      }

      return next();
    },
  }, async (request, reply) => {
    const { username, password } = request.body;
    const userData = await fastify.helpers.authentication.getUserTokens(username, password, azureConfig.CLIENT_SCOPE);
    await replyWithTokens(fastify, reply, userData);
  });

Continuing...

const getUserTokens = async (username, password, scope) => {
  const authUrl = `https://login.microsoftonline.com/${azureConfig.TENANT_NAME}/oauth2/v2.0/token`;
  // Additional authentication logic here
}

Desired Response:

{
    "Details about the user"
}

Actual Error Response Received:

{
    "error": {
        "code": "Authorization_RequestDenied",
        "message": "Insufficient privileges to complete the operation.",
        "innerError": {
            "date": "2022-01-14T20:40:30",
            "request-id": "9e2b5937-4bd0-4fdb-a1ae-1b22cef09772",
            "client-request-id": "9e2b5937-4bd0-4fdb-a1ae-1b22cef09772"
        }
    }
}

Answer №1

In order to access the managers of other users within your organization, you must be granted the User.Read.All delegated permission.

https://i.sstatic.net/34g6O.png

Once the permission has been allocated, admin consent is required for the same.

Afterward, you will have the ability to retrieve information about the managers of other users in your organization.

You can initially test this functionality in Graph Explorer. Upon successful testing, you can then adjust your JavaScript code accordingly.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What steps should I take to ensure that model updates are applied by NgJsTree?

One of the challenges I encountered in my project involved integrating various technologies such as JQuery, JSTree, Angular, and NgJsTree. Despite updating the treeData model, the changes were not being reflected in the tree structure. tcwsApp.servi ...

Having issues with the right margin in HTML5 canvas and struggling to remove the scroll bar

I am struggling with adjusting the margins of my canvas to ensure equal spacing on both sides without any horizontal scroll bars. Desired Outcome: Equal margin on both sides of canvas without any horizontal scroll bars. Issue: The margin-right property i ...

I encountered an issue where the variables in my environment files were returning as undefined when I tried to access

After creating my Vue application using vue/cli with the command vue create my-vue, I decided to build the project in next mode. Following the steps outlined in the Vue documentation, I created a .env.next file at the root of the project with the following ...

Visibility of Code in AngularJS

After inspecting the source code of a website built with Angular today, I came across a snippet that made me ponder whether it's advisable to have such elements visible to everyone. ul class="nav-account desktop-only" ng-show="!User.isAuthenticated" ...

Utilizing a React Hook to set data by creating a pure function that incorporates previous data using a thorough deep comparison methodology

I have come across the following code snippet: export function CurrentUserProvider({ children }) { const [data, setData] = useState(undefined); return ( <CurrentUserContext.Provider value={{ data, setData, }} & ...

After an ajax request, Intersection Observer is incorrectly detecting the number of intersecting images

UPDATE: After refining my functions, I have made necessary adjustments in this post I am looking to incorporate lazy loading for images into a website. These images are part of various galleries that load asynchronously based on the user's selection. ...

Unable to retrieve the /socket.io/socket.io.js file in the client-side application

My server side application is currently hosted on heroku: The code snippet that is relevant to this issue is as follows: const express = require('express'), app = express(), server = require('http').createServer(app), ...

What is the process for utilizing a custom plugin within the <script setup> section of Vue 3?

//CustomPlugin.js const generateRandomValue = (min, max) => { min = Math.ceil(min); max = Math.floor(max); const random = Math.floor(Math.random() * (max - min + 1)) + min; console.log(random); }; export default { install(Vue) { Vue.conf ...

Navigate to specific routes only when a user is signed in using the Route render feature in React Router

I'm having trouble figuring out how to display the signIn component when currentUser is not detected. There are no errors, but it's rendering an empty component because of the value "currentUser = null". <Routes> <Route exact path=&ap ...

After two HTML injections, Javascript ceases to function properly

I am in the process of developing a chat feature for my website. The layout includes a conversation section on the left and a list of users on the right. When a user's div is clicked, their ID is transmitted to the Django back end. Subsequently, full ...

Display a loading image when the button is clicked and the page is loading

I have encountered an issue with my project. I am using two webpages, webpage XXX for input and webpage YYY for output. The processing time takes approximately 2 minutes, so when I click the button on webpage XXX, it displays a white screen until the proce ...

Navigation bar transforms color once a specific scroll position is reached

My website features a sleek navbar fixed to the top of the window. As users scroll past a specific div, the background color of the navbar changes seamlessly. This functionality has been working flawlessly for me thus far. However, upon adding anchor link ...

What could be the reason for operators like tap and map not being invoked on the inner observable when combineLatest is used?

Can you clarify why the operators tap and map of inner observable are not being called? Shouldn't combineLatest subscribe to the observables it receives in obsArr? Why are these operators not triggered by this subscription? const obsArr = []; [[1, 2 ...

Pressing a key will initiate a time delay before

I have a coding challenge where I need to navigate through a sprite sheet using setTimeouts. Everything is functioning as expected, but I am curious about implementing a feature that allows me to skip frames by pressing the "m" key. Essentially, I want it ...

JavaScript Control for Embedding Facebook Videos (Start / Stop)

I need assistance on how to correctly utilize this API with the code provided in the following URL: https://developers.facebook.com/docs/plugins/embedded-video-player/api/#control-reference https://i.sstatic.net/jQQeN.png window.fbAsyncInit = function() ...

Tips for creating horizontal dividers with CSS in Vuetify using <v-divider> and <v-divider/> styling

Currently, I am working on a project using Vue.js and adding Vuetify. However, I need to use a component. .horizontal{ border-color: #F4F4F4 !important; border-width: 2px ; } <v-divider horizontal class=" horizontal ...

Is it possible to trigger the @click event in Vuejs when utilizing v-html to render HTML content?

Here is an interesting HTML scenario: errorText: '<a class="button" @click.prevent="enableExceedable(issue.mapping)">Enable exceedable limits</a>'; I am trying to insert this string into the following div: <div v-if="hasIssue != ...

Incorporate a smooth transition effect to a dynamically resizing div button

In my current setup, I have 3 buttons that can toggle between different visible divs. In the future, I may add more buttons to switch between additional divs. At the moment, the first div is active (display set to block), while all other divs are hidden ( ...

Encountered a MongoNetworkError while attempting to establish a connection with the server at localhost:27017. The initial connection failed due to an ECONNREFUSED error at 127.0.0.1:

Encountered a MongoNetworkError: failed to connect to server [localhost:27017] on first connect [Error: connect ECONNREFUSED 127.0.0.1:27017 If I reinstall MongoDB, the code works fine. However, I am looking for a permanent solution. [error:MongoNetworkE ...

Looking to conceal an <hr> element using jQuery's slideToggle function and then reveal it when clicked once more

I recently embarked on my journey to learn jQuery. I encountered a challenge with a simple button that triggers the slideToggle function to show/hide a div. Directly above this toggled div, there is an break line which I want to hide when the button is in ...