I have SPFx webpart where i want to create form which have Outlook locations, meeting rooms, there is one service account which should block meeting room and cancel meeting and edit meeting.
Also, I have registered azure app where i will have microsoft graph permissions but i am not sure how to connect it and use it in spfx webpart.
Swesh SPosted Sep 21, 2024, 8:19 AM
Hi Prachi,
1. how to use service accpunt as only service accpunt will have access to read outlook properties (read locations, block meeting rooms)
follow this MS article to authenticate a particular user - https://learn.microsoft.com/en-us/graph/auth-v2-user?tabs=http
to get read only access to the outlook meeting rooms - https://learn.microsoft.com/en-us/exchange/recipients/room-mailboxes?view=exchserver-2019
Permissions lists in general - https://learn.microsoft.com/en-us/graph/permissions-reference
2. how to connect app to spfx
actually Aman has provided a code sample below, for your ready to use I am attaching a couple of code snippets for ease of your use
Web Part Code (React Example)
src/webparts/myGraphWebPart/MyGraphWebPart.ts
src/webparts/myGraphWebPart/components/MyGraphWebPartComponent.tsx
prachi guptaPosted Sep 16, 2024, 5:56 AM
Hi Swesh,
Thank you for helping here!
Can you Please suggest how to connect this azure registered app in spfx, i already tried MS Graph explorer to test these apis but i want to know how to connect app to spfx and how to use service accpunt as only service accpunt will have access to read outlook properties (read locations, block meeting rooms)
Than you in advance for help!!
prachi guptaPosted Sep 16, 2024, 5:43 AM
Hi Aman,
Thank you for posting reply!
I have two queries regarding the same.
1. In step 2, Regarding APi permissions, do we need to have them in organizational level,??? I have only User. Read.all permissions under api access in organizational level and when i try to use msgraphclientv3 to send permissions it does not get displayed in sharepoint admin center.
2. I want to block meeting room fetch locations on behalf of service account as we can not give permissions to all users to access outlook, how can i use this in spfx. How to connect azure app in spfx, where to add app id, secret?? How to use service account instead of current ligged in user context,???
Thank you in advance!!
Aman GuptaPosted Sep 14, 2024, 10:17 AM
Hi Prachi,
To connect your SPFx (SharePoint Framework) web part with Microsoft Graph and manage Outlook locations, meeting rooms, and meeting operations (block, cancel, edit), follow these steps:
1. Set Up Microsoft Graph Permissions
These can be delegated (for user-based permissions) or application permissions (for service account scenarios).
2. Add Azure AD App to SharePoint
3. Install Required NPM Packages
You'll need the following packages in your SPFx solution:
4. Configure Microsoft Graph Client
In your SPFx web part, you need to configure the Microsoft Graph client. The @pnp/graph package helps with this.
Example to get started:
5. Blocking/Managing Meeting Rooms and Events
Use Microsoft Graph API's Calendar endpoint to block rooms or manage meetings:
6. Handling Authentication in SPFx
If you're using delegated permissions (i.e., the service account), you must authenticate the user.
Note: This code examples are taken from my exisiting code project, you can change it according to your requirments.
Swesh SPosted Sep 13, 2024, 6:50 PM
Hi Prachi,
You are looking for a whole solution, cut this into pieces
1. Register an app in Azure for MS Graph, follow these steps
https://learn.microsoft.com/en-us/graph/auth-register-app-v2
2. Once the app is registered, you would be able to get access token for an account following these steps
https://learn.microsoft.com/en-us/graph/auth-v2-user?tabs=http
3. You need to create meetings / book meeting rooms based on outlook locations pre-built or configured using service account following the steps below
https://learn.microsoft.com/en-us/graph/api/resources/onlinemeeting?view=graph-rest-1.0
https://learn.microsoft.com/en-us/graph/choose-online-meeting-api
4. Try api tools like POSTMAN with the access token generated using step 2 and see how if it succeeds.
https://learn.microsoft.com/en-us/graph/use-postman
Once all done, you can use the regular method of building the logic in spfx webpart.
Hope this helps
Thanks
Swesh