Good news: the medieval webkey authentication for Business Central API has finally been deprecated.
In this first article I am going to present a little overview of the secure and modern OAuth protocol with a “delegated permission” sample.
In next article I will describe an “Application permissions” implementation for an application that runs as a background service or daemon without a signed-in user. I am going to describe how I refactored an existing Xamarin mobile application that is currently directly getting and posting data to Business Central APIs.
IT’S TIME TO MOVE TO AZURE
Login in Azure Portal https://portal.azure.com/ , go to “All Services”, search “App Registration” and select “App registrations” list item.
Create a new registration.
Configure your application registration name and the redirect URI As Web with the URL “https://businesscentral.dynamics.com/”.
Or even better “https://businesscentral.dynamics.com/OAuthLanding.htm“
Note down the “Application (client) ID” GUID, this is the “CLIENT ID” we are going to use in Insomia.
Select “API permission” blade,
Configure as in picture.
Go the “Certificate and secrets” blade.
Add a new “Client secret”
The “Client secret” and “Secret ID” will be generated,
Please notice that the “Client secret” is shown in clear text ONLY after the first generation and it will NEVER EVER be shown again. If lost you will need to generate a new one. There is not way to recover an existing “Client secret”.
Copy the “Value”, we are going to use it in Insomia as “CLIENT SECRET”.
TEST WITH INSOMNIA
Here are all mandatory parameters to make an OATH request:
Token-Name: Give the appropriate Token Name
Grant Type: Authorization Code
Callback URL: https://businesscentral.dynamics.com/
Access Token URL:
Client ID: Client ID as in “ID” column in azure
Client Secret: Client Secret Value as in “Value” column in azure.
By using Insomnia you easily test the API:
The well known Microsoft Azure AD web page appears asking for the username.
And the password.. and it’s done.
Olisterr Tech blog
24th of December, 2020