I'm working on an asp.net core mvc application which requires a user to sign in to the application registered in Tenant A as multitenant App and available in Tenant A, B and C.
Users logging in into the app in Tenant A can use the app to get information from all tenants which enrolled the App (so A, B, C) and to which the user has access to via Graph API.
By using the tag [AuthorizeForScopes(ScopeKeySection = "AllRequiredScopes")]
, exceptions regarding access to the graph API for the tenant of the currently signed in user are handled just fine in the controller. This means if a user from Tenant A is logged in into the app, GraphAPI-requests for tenant A which cause an exception are handled as expected.
However, if the user from tenant A wants to get data from tenant B, the tag does not redirect him to the correct endpoint. The user is always sent to https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize?...
, which takes the default Account (tenant A in the scenario). Obviously, this does not help in correcting error conditions like the user not being logged in into tenant B, missing consent, or similar.
Is there a way to modify the tag to use the tenant endpoint instead of the common endpoint or how can this be handled?
Thank you!