简体   繁体   中英

Why do I receive a 403 forbidden response when calling this endpoint with Angular, using the Microsoft Graph REST API?

Main question

I have been working on integrating the Microsoft Graph REST API into an Angular (version 10) application. I have followed the instructions given by the following tutorial on how to connect the Angular application to Microsoft Graph and sign in a user over Azure AD (by registering the app in app registration).

I have followed the tutorial every step of the way, and I have now decided I want to extend the application by getting the Teams chats I am a member of , over HTTP. I decided to create a simple test by printing out the results of the call to the browser console, but when I attempt to call it there is a HTTP 403 response ( "Failed to get license information for the user. Ensure user has a valid Office365 license assigned to them." ) I have attempted to do this with a student Office 365 account, and with my personal Microsoft account, but I continue to receive the same HTTP response.

Attempted solutions

When tested in the Graph Explorer, the correct response is received. I have added the student account to a Azure AD tenant where the personal account is a Global Administrator.

I have attempted to call the aquireTokenPopup , aquireTokenSilent and aquireTokenRedirect in the Method screenshot but to no avail (I still receive a 403 HTTP Forbidden response.) I have also looked through the documents listed on docs.microsoft.com , and looked at the different documentation for this 403 response, but I have not been able to make head or tail of what the 403 responses may mean - the student account has a valid Office 365 tenant while my personal account does not and I get the same response.

Why do I receive this response, even when I have given permission in the Popup, as well as configuring to allow the endpoint in Azure?

Has something been wrongly configured?

Have I used the wrong type of authentication? (should I have used Azure AD B2C?)

Screenshots

Azure permissions

Browser console screenshot

Browser HTTP screenshot

Method screenshot

Login method screenshot

app.module msal configuration

Post comments as answers:

You must meet the following two points:

  1. You must use a work or school account, it does not support Microsoft personal accounts.

  2. Your account must have an Office365 license.

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM