As outlined in the following GitHub Issue:
https://github.com/microsoft/ALAppExtensions/issues/22935
If we call the procedure AcquireApplicationTokenWithSecret with an invalid applicationid the accesstoken is empty, but I don't know why and addtionally I don't get any error, that I can report to the user.
I would expect that this is returned as an error to business central.
///
/// Gets the access token via the Client Credentials OAuth2 v2.0 grant flow.
///
/// The Application (client) ID that the Azure portal – App registrations experience assigned to your app.
/// The Application (client) secret configured in the Azure Portal - Certificates & Secrets.
/// The identity authorization provider URL.
/// The redirectURL of your app, where authentication responses can be sent and received by your app. It must exactly match one of the redirectURLs you registered in the portal. If this parameter is empty, the default Business Central URL will be used.
/// A list of scopes that you want the user to consent to.
/// Exit parameter containing the access token.
[NonDebuggable]
[TryFunction]
procedure AcquireTokenWithClientCredentials(ClientId: Text; ClientSecret: Text; OAuthAuthorityUrl: Text; RedirectURL: Text; Scopes: List of [Text]; var AccessToken: Text)
begin
OAuth2Impl.AcquireTokenWithClientCredentials(ClientId, ClientSecret, OAuthAuthorityUrl, RedirectURL, Scopes, AccessToken);
end;
In the event log I see the following:
Message Microsoft.Dynamics.Nav.LicensingService.Model.Exceptions.LicenseServiceAdalServiceException in AcquireApplicationTokenWithSecret (action id: c64ad927-1b72-4fe6-a6a4-b605c16c285f): AADSTS700016: Application with identifier '00000000-0000-0000-0000-000000000000' was not found in the directory 'our tenant Name xxx'.

Business Central Team (administrator)
Thank you for this suggestion! Currently this is not on our roadmap. We are tracking this idea and if it gathers more votes and comments we will consider it in the future. Best regards, Business Central Team