Skip to main content
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested answer

How to connect to Dynamics 365 Web API using OAuth 2.0 in c#?

(0) ShareShare
ReportReport
Posted on by

Hello Community,

I need to make a connection & CRUD in dynamics 365 using oAuth2 or using Azure App details(ClientID, Client Secret) in C# code,  Can anyone suggest the way to achieve that using Dynamics CRM SDK?  Is there any other method or SDK for oAuth2?

Thanks

  • Suggested answer
    cloflyMao Profile Picture
    25,208 on at
    RE: How to connect to Dynamics 365 Web API using OAuth 2.0 in c#?

    Hi Sandhya,

    SDK and Web API(OAuth 2) are two different approaches:

    .NET framework is required to use SDK, and SDK uses Organization service to connect to Dynamics environment.

    Web API could be regarded as http request, hence we only need some system libraries(such as system.net.http) without importing SDK assemblies if we are working in Web API style.

    (To be precise, besides system libraries, Active Directory assembly is required to authenticate Azure app.)

    Please refer to following article, it gives complete steps to register Azure app and a sample C# code.

    https://www.c-sharpcorner.com/article/generate-access-token-for-dynamics-365-single-tenant-server-to-server-authentica/

    Regards,

    Clofly

  • Suggested answer
    Wahaj Rashid Profile Picture
    11,321 on at
    RE: How to connect to Dynamics 365 Web API using OAuth 2.0 in c#?

    Hi,

    Please refer to below link which explains how to connect D365 Web API using OAuth 2 with C# Code sample:

    nishantrana.me/.../

    Best,

    Wahaj

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Now Available: 2025 Release Wave 2

Quick Links

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Holly Huffman Profile Picture

Holly Huffman 103

#2
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 96 Most Valuable Professional

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 51 Most Valuable Professional

Product updates

Dynamics 365 release plans