Authentication error on Custom Data services

I am creating data integration from my D365 (on-premise and cloud). I am trying to pull and push data from my D365 from external codes. I followed instructions from technet, cookbook, and github. I am using Custom services (Json, SOAP, OData). Please see document below for details of the integration including code and error. Hope anyone can help me to identify what causes the error. I am currently ising the VM from LCS.

D365 Integration Error.docx (959 KB)

Here are a few comments:

  • Your requirement “to integrate both environments without exposing On-premise to external network” could be implemented by a reverse proxy, without staging database.
  • Azure Active Directory application form is used for Web API apps, but you’ve registered the app as “native”. Choose one of these two ways.
  • What did you change GetAuthenticationHeader? You shouldn’t change the name of the authentication header. Also the code doens’t look like the current version.
  • The URL of your environment looks very suspicious. Are you trying to connect to a downloaded VM?
  • Why your ClientConfiguration doesn’t contain any authentication information? You see that the SOAP service explicitly complain that “there is insufficient account information to log you on”.