We have a use case where we would like to pull data out of Dynamics Business Central and display that data in an app.
In order to get this working, we needed to register an application inside of Azure Portal and give it permission to the Business Central API.
One of the important bits with regards to azure app registration is to configure the app to allow access using its own credentials instead of user credentials. (We dont want each active directory user to have to login in order to get an access token).
Tokens issued by Microsoft identity expire after 1 hour by default.
I have read about the frustrations of a few other users’ trying to use a connector function with the Ouath (Admin) option which after 1 hour you would need to refresh the connector function in order to get a new token and this wont work for us.
So as a workaround I suggest creating 2 connector functions and the application that calls the connector functions will be responsible for passing output from the 1st connector function (get the access token) to the second connector function (make the call to business central).
the 1st connector function will look something like this…
you have to specify the following request body
- grant_type : client_credentials
- scope : whatever your scope is, we use .default
- client_id : your client id (azure application id)
- client_secret : the secret you created in the azure application
Create an output for the connector function that will grab the access_token from the response json.
The tulip application that calls the 1st connector function must handle getting the new token and then pass it to the 2nd connector function as input.
The 2nd connector function looks something like this…
I hope this is helpful.