Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Azure by (13.1k points)
I have created a REST API using C# and I want to access a token from the server for that I need to authenticate it with Azure AD. Can anyone help me how I can able to achieve it?

1 Answer

0 votes
by (26.7k points)

At first, you need to create a user credential:

UserCredential uc = new UserCredential(user, password);

After that, you need to call AcquireToken() function using that user credential:

public AuthenticationResult AcquireToken(string resource, string clientId, UserCredential userCredential);

public Task<AuthenticationResult> AcquireTokenAsync(string resource, string clientId, UserCredential userCredential);

I hope this will work.

Want to become an Azure expert? Join Microsoft Azure Training now!!

Want to know more about Azure active directory? Watch this video on Azure Active Directory :

Browse Categories

...