Today, I want to shed light on a common challenge we may encounter when generating tokens in .NET adapters for integrating Dynamics 365 Finance and Operations with third-party applications.
In the code snippet below, the HttpRequestMessage class is used to pass essential client credentials for the app registered in the Azure portal. This approach works seamlessly in a cloud environment.
Token generation in .NET adapter using HttpRequestMessage |
There are numerous blog posts available on registering an app, and I'll provide a helpful link for your reference here from Microsoft Learn Register an application with the Microsoft identity platform.
Unfortunately, the earlier approach doesn’t work for on-premises instances of Dynamics 365 Finance and Operations. After experimenting with several methods, I found an alternative solution. As shown below, I used a PowerShell script to generate the token.
PowerShell script to generate token |
In my .NET adapter class, I then used the PowerShell script to retrieve the token, as demonstrated in the code snippet below.
I hope this post helps save you significant time and effort if you're facing a similar issue. I’d love to hear your feedback as well!
No comments:
Post a Comment