-
Notifications
You must be signed in to change notification settings - Fork 357
How To for OnBehalfOf services access sample
Yury Opolev edited this page Oct 22, 2020
·
8 revisions
In order to access various services within a tenant on behalf of any user in the tenant, you'll need to set up an Azure AD Application with delegated permissions to the services, then grant admin consent to the services. Here are the steps for doing this:
Setup single tenant application:
- Sign into Azure portal under admin user, and add Application registration:
- Under supported Account types, specify “Accounts in this organizational directory only”, and register the application:
- Add Redirect URI to the application, go to “Authentication” -> “Platform Configurations” -> “Add a platform”, choose “Web” and specify “Redirect Uri”. Set the Redirect Uri value to
https://businesscentral.dynamics.com/OAuthLanding.htm, so it will be possible to receive information from Azure AD to acquire tokens for the application:
- Add client secret:
![[APP REGISTRATION STEP 4.1]](https://bctechsmstorage.blob.core.windows.net/bctech-images/003.png)
- Add Application ID URI, go to “Overview” -> “Add an Application ID URI” -> “Set”. Normally Application ID URI will be api://{Application ID}:
![[APP REGISTRATION STEP 5.1]](https://bctechsmstorage.blob.core.windows.net/bctech-images/005.png)
![[APP REGISTRATION STEP 5.2]](https://bctechsmstorage.blob.core.windows.net/bctech-images/006.png)
- Now, add delegated permissions for this application, so it can access all needed services, such as Business Central, SharePoint, Power BI, Graph, and so on. Go to "API Permissions" -> "Add a permission", and add the required permissions:
![[APP REGISTRATION STEP 6.1]](https://bctechsmstorage.blob.core.windows.net/bctech-images/009.png)
![[APP REGISTRATION STEP 6.2]](https://bctechsmstorage.blob.core.windows.net/bctech-images/010.png)
![[APP REGISTRATION STEP 6.3]](https://bctechsmstorage.blob.core.windows.net/bctech-images/011.png)
![[APP REGISTRATION STEP 6.4]](https://bctechsmstorage.blob.core.windows.net/bctech-images/012.png)
- After permissions are added, grant admin consent to it:
![[APP REGISTRATION STEP 7.1]](https://bctechsmstorage.blob.core.windows.net/bctech-images/014.png)
Now, the application is fully setup. It has an Application ID URI, a Secret, and a Redirect URI, and has delegated access to all needed services within the given tenant. This means that it is now possible to acquire on-behalf tokens.
![[APP REGISTRATION STEP 1]](https://bctechsmstorage.blob.core.windows.net/bctech-images/001.png)
![[APP REGISTRATION STEP 2]](https://bctechsmstorage.blob.core.windows.net/bctech-images/002.png)
![[APP REGISTRATION STEP 3]](https://bctechsmstorage.blob.core.windows.net/bctech-images/016.png)
![[APP REGISTRATION STEP 4.2]](https://bctechsmstorage.blob.core.windows.net/bctech-images/004.png)
![[APP REGISTRATION STEP 5.3]](https://bctechsmstorage.blob.core.windows.net/bctech-images/007.png)
![[APP REGISTRATION STEP 6.5]](https://bctechsmstorage.blob.core.windows.net/bctech-images/013.png)
![[APP REGISTRATION STEP 7.2]](https://bctechsmstorage.blob.core.windows.net/bctech-images/015.png)