Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Answered

Am I doing this right? Integrating BC to our SaaS

Posted on by 4
Hello!
 
I'm a software developer working with a SaaS application.
 
Our application is on the accounting industry, and we're planning to offer some features to business central users, whereby the SaaS application would need to fetch invoices and customers from the user's Business Central account.
 
The way I'm setting up this integration is:
 
1- I added a new App Registration in our SaaS's Azure. 

For this new app registration I configured the following permissions:
  • AdminCenter.ReadWrite.All
  • API.ReadWrite.All
  • Automation.ReadWrite.All
  • app_access
2- In our web application I then ask the user what his Tenant Id is;
 
3- With the Tenant Id, I call this endpoint:
 
"https://login.microsoftonline.com/{tenantId}/v2.0/adminconsent?" +
"client_id=" + _settings.LikvidoApplicationId +
"&redirect_uri=" + HttpUtility.UrlEncode(redirectUri) +
"&scope=" + HttpUtility.UrlEncode("https://api.businesscentral.dynamics.com/.default")
 
The Client Id and Redirect URI are being taken from our SaaS app registration.
 
4- When going to that link in the browser, it will present the Microsoft's Admin Consent screen.  The user clicks "Yes, I consent" (or whatever is in the confirmation button)
 
5- User is redirected back to my SaaS.  I can validate the admin consent has been given.
 
6- Now I instruct the user to give permissions to my SaaS Client Id, in his Business Central. So he goes to "Microsoft Entra Applications" in his business central, and gives my Client Id (that I created in step 1) the state "Enabled" and Permission "D365 BUS FULL ACCESS"
 
7- To use the Business Central API, my SaaS gets an access token from the SaaS app, using:
 
$"https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/token";
 new("grant_type", "client_credentials")
 new("client_id", clientId)
 new("client_secret", clientSecret)
 new("scope", "https://api.businesscentral.dynamics.com/.default")
 
The client Id and client secret at those from my app registration from step 1. The Tenant Id from the user's Azure.
 
8- With an access token it can then fetch the list of companies from Business Central, or invoices, or customers. For example:
 
var companiesEndpoint = $"https://api.businesscentral.dynamics.com/v2.0/{tenantId}/production/api/v2.0/companies";
WithHeader("Authorization", "Bearer " + token)
 
 
This works fine.  BUT, I'm in doubt if it's the best process to integrate my SaaS with business central...
 
My main concern is... It seems there are 2 major steps required, the adminconsent and the granting of permissions from BC to my client.
 
Are both necessary here?
 
Do you recommend anything different, to make this process easier for the user of my SaaS? 
 
Thank you, I appreciate any help with this 🙂
 
  • Verified answer
    Yi Yong Profile Picture
    Yi Yong 874 Super User 2024 Season 2 on at
    Am I doing this right? Integrating BC to our SaaS
    Hello,
     
    Admin Consent and Granting of permissions is a one-time setup for a new Entra ID/App Registration.
    Usually, it will be done on Business Central itself after step#1. Right after creating the app registration, head to Business Central to add the Entra ID, Give Consent and Provide the necessary permissions.
     
    On the integration side, you will need to get a token from step#7 and use the token for API endpoint step#8.
  • Suggested answer
    Sami Ullah Profile Picture
    Sami Ullah 280 on at
    Am I doing this right? Integrating BC to our SaaS
    Hi,

    Your Business Central integration setup looks good overall. Both admin consent and permission granting are needed because:

    Admin consent lets your SaaS access the tenant's resources through Business Central’s API, ensuring security by getting approval at the organization level.

    Business Central permission granting allows your app to work within the system.

    If you're concerned about admin consent, you can opt for Delegated Permissions instead of Application Permissions.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,572 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,706 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans