사실 모든 클라이언트 응용 프로그램은 AAD에 등록해야합니다.
콘솔 앱도 Azure AD에 등록되어 있어야하므로 클라이언트 ID 및 클라이언트 리디렉션 URL은 있지만 클라이언트 비밀은 유지되지 않습니다. 그런 다음, 다음 코드는 작동합니다 :
void Main()
{
var clientId = "client-GUID";
var clientUrl = new Uri("redirect-url"); //can be anything starting with localhost
var tenant = "name of your AAD tenant";
string authority = "https://login.windows.net/" + tenant;
string resource = "https://outlook.office365.com"; ///put id or url of resource you're accessing
AuthenticationContext authenticationContext = new AuthenticationContext(authority, false);
Console.WriteLine("Trying to acquire token");
var pp = new PlatformParameters(PromptBehavior.Auto); //this brings web prompt
var token = authenticationContext.AcquireTokenAsync(resource, clientId, clientUrl, pp, UserIdentifier.AnyUser).Result;
Console.WriteLine("Got the token: {0}", token.AccessToken);
}
단일 페이지 JS 응용 프로그램은 AD 인증 – Justin
https://github.com/Azure-Samples/active-directory-dotnet-graphapi-를 사용하는 AD에 등록 될 필요가있다 콘솔? – 4c74356b41
콘솔 응용 프로그램이 Azure AD에서 보호하는 웹 API에 액세스하는 샘플 - https://blogs.msdn.microsoft.com/benjaminperkins/2016/10/20/how-i-connected-a-console-application-to- a-web-api-protected-by-a-azure-active-directory / – alwayslearning