We have been searching and searching to find examples of how to get an OAuth token in al code in our codeunit. We can successfully get the token in Postman, so I know all the credentials are correct. But finding examples on the web of how to do this has proven to be extremely difficult.
I did find this .al page from Microsoft that looks like it has an example using OAuth2.AcquireTokenWithClientCredentials
but we can't get it to work. https://github.com/microsoft/BCTech/blob/master/samples/OAuth2Flows/TestOAuth2Flows.Page.al
Does anyone have a working example of this?