'Azure Ad multitenant applications registration with client credentials flow
Lets assume I have a service in tenant A which should consume API from a service registered in tenant B. As per Microsoft guides, I should:
- register serviceA in tenant A
- register serviceB in tenant B
- expose API of serviceB
- create a couple of appRoles in serviceB
- register serviceB in tenantA by executing following get request: https://login.microsoftonline.com/{tenantA-id}/v2.0/adminconsent?client_id={serviceB-id}&scope={serviceA-id}/.default
- serviceB should appear in Enterprise Application blade which is ok.
- add permissions from serviceB to serviceA
In this schema I see two weird things. First one is the token obtaining process. Since serviceA app is not registered in tenantB, serviceA cannot obtain roles in token in tenantB directory.
Also I dont see any tenantBs' admin consents in this flow. The problem is tenantAs' admin could add serviceB approles to his app without tenantA admin acceptance which is weird in my opinion.
The only way to obtain token for serviceA in tenantB with roles is to add serviceA in tenantB. So both apps should be in Enterprise Applications blade of both tenants. Or I took a wrong turn somewhere?
Solution 1:[1]
You need to:
- Create/add a servicePrincipal for serviceA in tenantB in order to assign it appRoles in serviceB.
- Consent serviceA with scope serviceB/.default in tenantA
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | AlfredoRevilla-MSFT |