Apr 25 2023 06:50 AM - edited Apr 25 2023 07:20 AM
Hi everyone. I have a web app that user can create an online meeting room link, attach it to an email and send it to the guests.
Initial configuration:
const pca = new PublicClientApplication({
auth: {
clientId: process.env.MS_CLIENT_ID,
authority: process.env.MS_AUTHORITY,
redirectUri: process.env.MFE_CONTAINER_URL,
},
cache: {
cacheLocation: 'sessionStorage',
storeAuthStateInCookie: false,
},
})
<MsalProvider instance={pca}>
</MsalProvider>
When user select microsoft teams option:
const { instance, accounts } = useMsal()
try {
let userToken = await instance.acquireTokenSilent(request)
let onlineRoom = await createRoom(userToken, task)
if (onlineRoom?.chatInfo) {
return onlineRoom?.chatInfo?.threadId
} else {
return onlineRoom?.error
}
} catch (e) {
try {
let userToken = await instance.acquireTokenPopup(request)
let onlineRoom = await createRoom(userToken, task)
if (onlineRoom?.chatInfo) {
return onlineRoom?.chatInfo?.threadId
} else {
return onlineRoom?.error
}
} catch (e) {
console.log(e)
}
}
const createRoom = async (userToken, task) => {
const urlApi = 'https://graph.microsoft.com/v1.0/me/onlineMeetings/createOrGet'
const headers = new Headers()
const bearer = `Bearer ${userToken.accessToken}`
headers.append('Authorization', bearer)
headers.append('Content-Type', 'application/json')
const attendees = task.executors.map(executor => {
return {
identity: {
user: {
displayName: executor.name,
},
},
role: 'attendee',
}
})
const options = {
method: 'POST',
headers: headers,
body: JSON.stringify({
startDateTime: moment(task.startDate).format(
'YYYY-MM-DDTHH:mm:ss-00:00',
),
endDateTime: moment(task.finalDate).format('YYYY-MM-DDTHH:mm:ss-00:00'),
subject: task.title,
participants: {
organizer: {
identity: {
user: {
displayName: userToken.account.name,
},
},
},
attendees: attendees,
},
externalId: task.id,
}),
}
return fetch(urlApi, options)
.then(response => response.json())
.catch(error => console.log(error))
}
The point is that it's not clear for me (I havn't found any doc pointing this) that it seens that the user need to have a 365 business plan. I have some user that only have a Microsoft Teams Essencial plan, for those user, I only get a 400 Bad Request response. I tryed an acccount with 365 business basic plan and the given code works fine. Graph API for online meeting only works for 365 business users? There's realy no other plans suport? Am I doing something wrong? Thanks and sorry for the problems.