I am developing a web application that reads the Microsoft calendar of the user who has logged in, my problem is that with the @hotmail or @outlook accounts it reads them without problem but when using an @onmicrosoft account it appears that the account does not exist , when can I log in directly to the office365 website.
within the azure portal I have enabled being able to log in with: “Accounts in any organizational directory (any Microsoft ID tenant Sign in – multi-tenant) and personal Microsoft accounts (e.g. Skype, Xbox)
The app or API can be used by anyone with a work or school account, or a personal Microsoft account. Office 365 subscribers are also included.” as shown in the picture below.
and when trying to log in this appears:
translation: This Microsoft account does not exist. Please indicate another account or get a new one.
Entering the part of the code, this is the part that contains the permissions, authorizes the user and proceeds to read their calendar
my API delegated permissions are
User.Read – Login and read user profile
Calendars.Read – Read user calendars
Calendars.Read.Shared – Read shared and user calendars
2. Part that handles user login and validation:
document.addEventListener('DOMContentLoaded', async function() {
const msalInstance = new msal.PublicClientApplication(msalConfig);
try {
await msalInstance.loginRedirect(loginRequest);
} catch (error) {
console.error('Error during authentication:', error);
}
msalInstance.handleRedirectPromise().then(async function(response) {
if (response !== null && response.account !== null) {
// Get calendar events
const events = await getCalendarEvents(response.accessToken);
// Render the calendar with the events obtained
renderCalendar(events);
} else {
console.error('No user account provided.');
}
});
});
I don’t know if the error could be because to use Office365 accounts you would need another type of authorization or delegated/Application permissions
Thanks a lot!