I am currently integrating a 3rd party application with Dynamics D365 using Odata. I did this a few months ago and it worked fine. I followed the same procedure this time as well.
I registered the app as a web app in Azure Active Directory. Acquired the Directory ID, App ID, client secret and selected the Microsoft Dynamics ERP API and granted the needed delegated permissions.
I created the service account in D365 F&O. I can acquire a token from https://login.microsoftonline.com/[tenant_id]/oauth2/token and it is successful. But when I try to access the data I am greeted with a 401 Authentication failed.
I checked if TLS versions enabled in the browser and it supports 1.0 , 1.1 & 1.2
I decoded the bearer token at https://jwt.ms/ and all the needed information was inside the token. All permissions in AAD was granted by an administrator and was successful. Tried generating a new client secret and entered it at all the appropriate places. Still authentication failed. Even contacted Microsoft who could not help me.