mgwojciech / unit-test-samples

Sample projects for unit testing in M365 stack
https://mgwdevcom.wordpress.com/
MIT License
18 stars 5 forks source link

Make a query to a sharepoint site in a multi-tenant scenario #3

Open ayoubqrt opened 9 months ago

ayoubqrt commented 9 months ago

Hi thank you for you work, I found some useful resources particularly on your mgwdev-m365-helpers repo. So I wanted to use the sp-react application in a multitenant scenario.

Context :

Scenario :

Have you any ideas, do you think it's possible ?

mgwojciech commented 9 months ago

Hi Mate :) Great to hear someone finds it useful.

When it comes to guests in such scenario, there is one thing You have to consider - even if Your app is registered as a multitenant, You have to know to which tenant You want to authenticate at runtime level, in other words - when navigating to /auth page, You have to already know to which tenant You want to authenticate to. If not - MS login page will always assume You want to authenticate to Your "main" tenant.

This of course presents a small problem - if You want to keep Your app functioning as multi tenant You have to figure out when user is using the app as a guest, and when as a internal user. I would suggest using link with ?tenantid= when sharing the link to Your app, than if Your app detects tenant-id in query parameter - it uses it in auth endpoint, if not - go with common (or organizations).

If You are building an app for one customer (or You can handle that with subdomains) - there is no problem :)

Hope that helps :)