Hi everyone,
I'm currently trying to call an Oauth Business Central API from Business Central with a grant type authorization code.
I've set up an On Premise business central base with OAuth authentification by following every steps on this documentation https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/administration/register-app-azure (registering in Azure etc.)
The OAuth setup works well in Postman. I've setup the authentification as Authorization code, and the flow to obtain the security token works fine
I've exposed some custom API on my base and everything works well.
My issue appears when I'm trying to retrive the security token to call these same APIs in AL. I have issues that I don't seem to find solutions to with the grant type used here.
I have tried first to retrive my security token using the procedure AcquireTokenByAuthorizationCode in codeunit 501 "OAuth2" by sending the same info I'm sending in postman
But I only get this response back
(the sentence in french says Sorry we're having troubles to connect you).
The part about the request body seems strange to me as it looks like a bad request construction, but since I don't have any control on how the request is set up, it looks like the procedure simply does not work ?
I've also tried to create my own request to retrieve the authorization token, but when the return of my request should have an http code 302 and open a browser for me to authentificate into my azure account, i only get an http 200 with the page's html code in the response
Has anyone done this before ?
Thanks