basic code sample to create service principal in tenant?

Viewed 33

I made an app that is designed to run as a service without user intervention. (it works correctly in my own AAD, it does oAuth call and gets a token and everything is lovely ;))

It's application object lives in my Azure active directory and is configured as multi tenant and has a client secret.

Now I want to get it listed in another AAD tenant and be permitted to access data. Idealy I would want to have a helper application with a button to click after which my app is authorized to run from the users' AAD and access their data/api. From what I read, the granting of the permissions by an admin would create a service principal in the admin's AAD and i'm done.

Can anybody help me with the code that I can call with the "magic" button?

1 Answers

You essentially need to get you code to work with the Request the permissions from a directory admin process. Now that step is at almost the very end of a much involved process.

Multi-tenancy and service principal provisioning across tenants is a fairly involved process actually, so providing links to some material that would help walk you through those.

  1. Sign in any Azure Active Directory user using the multi-tenant application pattern
  2. Develop multi-tenant applications with Microsoft identity platform
  3. Integrate a multi-tenant SaaS web application that calls Microsoft Graph (aspnet core sample for a web App)
  4. Multi-tenant (SaaS) Angular single-page application that authenticates users with Azure AD and calls a protected ASP.NET Core web API (Javascript sample)
  5. Protect a multi-tenant SaaS web application and a Web API which calls Microsoft Graph on-behalf of the user with the Microsoft Identity Platform (aspnet core with a WebAPI)
Related