I seem to have run into an odd issue. I have a control add-in which uses a JS script to open up a url to an Azure portal login page, upon successful login - the URL contains an authorization code which can be used to obtain an Access Token. It seems that now, for some reason, whenever I call a window.location.href or window.location.search, the script just stops working, if I remove the line, it continues to loop as it should.
The whole point of the script is to loop every second until the URLcontains the “Code” parameter. Does anyone have any ideas what could be the issue?
Alternatively, perhaps anyone could suggest any other ways to retrieve an Access Token and a Refresh Token from an Azure app?
It seems to have the same issue. The page closes after authorizing, I can see the URI has the auth code that I need but the add-in doesn’t trigger the function that returns the code. Could this be an issue because it is being done on an On-Prem environment?
Alright, so I seem to have figured out what the cause of the issue is. The setup was incorrect within the OnPrem environment, specifically - the redirect URI. The hostname of the redirect URI most likely has to be the same as the BC’s, the https://businesscentral.dynamics.com/OAuthLanding.htm only works in SaaS. So either I have to do it within a cloud environment or set up my OnPrem server to use the https protocol instead of http.