How to connect to Dynamics 365 web services using OAuth?

«Connect to Microsoft Dynamics 365 web services using OAuth».

Before you can use OAuth authentication to connect with the Dynamics 365 web services, your application must first be registered with Microsoft Azure Active Directory.
Azure Active Directory is used to verify that your application is permitted access to the business data stored in a Dynamics 365 tenant.