0
votes

I have a service registered as a multi-tenanted Web API in an AAD tenant “A”. And a client registered as a web app in a different AAD tenant “B”. The question is, whether do I need any additional configuration on Azure portal in order for the client app in tenant “B” to successfully access the web API in the tenant “A” (app to app authentication) ? Does AAD support such scenario? Currently, I get Unauthorized status code as response from the service when the service is deployed to Azure.

The service in tenant A doesn’t show up when I try to manually manage permissions for the client app in tenant B. Is this step necessary or am I missing some config set up?

enter image description here

The service is built on asp.net MVC application and it uses JWT bearer authentication scheme. The client successfully acquires its token from its own AAD tenant. So it doesn't seem like an authentication issue. On the service side, I have added the client's tenant to be one of the valid token issuers as well.

I'm not sure if a service principal for the service app is created in the client's tenant automatically (the consent page has never showed up so far).

1

1 Answers

1
votes

The scenario is supported. You'll just have to consent to the API from tenant B first before it shows up in the list.

You can define your application permissions on the Web API as normal (check here).

Then you can go through consent for the API by accessing a URL like this:

https://login.microsoftonline.com/tenant-b-id/oauth2/authorize?client_id=your-api-client-id&response_type=code&redirect_uri=reply-url-defined-on-api&prompt=admin_consent

You'll have to replace 3 values there with yours:

  • tenant-b-id: the directory id for tenant B
  • your-api-client-id: The application id/client id of your API in tenant A
  • reply-url-defined-on-api: URL-encoded reply URL defined on your API in tenant A (e.g. https%3A%2F%2Flocalhost%2F)

That should then result in a service principal getting created in tenant B for the API, allowing you to assign app permissions to apps in tenant B.