다음을 통해 공유


Node.js용 Azure Active Directory 모듈

개요

중요

ADAL은 더 이상 사용되지 않습니다. 대신 애플리케이션 개발에 MSAL(Microsoft 인증 라이브러리)Microsoft Graph API 사용하는 것이 좋습니다.

자세한 내용은 다음 리소스를 참조하세요.

Node.js대한 Azure ADAL(Active Directory 인증 라이브러리) 을 사용하면 Node.js 애플리케이션이 AAD로 보호되는 웹 리소스에 액세스하기 위해 Azure AD 인증할 수 있습니다.

클라이언트 패키지

npm 모듈 설치

npm을 사용하여 Azure Storage 클라이언트 또는 관리 모듈을 설치합니다.

npm install adal-node

클라이언트 자격 증명 샘플의 이 예제에서는 클라이언트 자격 증명을 통한 서버 간 인증을 보여 줍니다.

const adal = require('adal-node').AuthenticationContext;

const authorityHostUrl = 'https://login.windows.net';
const tenant = 'your-tenant-id';
const authorityUrl = authorityHostUrl + '/' + tenant;
const clientId = 'your-client-id';
const clientSecret = 'your-client-secret';
const resource = 'your-app-id-uri';

const context = new adal(authorityUrl);

context.acquireTokenWithClientCredentials(
  resource,
  clientId,
  clientSecret,
  (err, tokenResponse) => {
    if (err) {
      console.log(`Token generation failed due to ${err}`);
    } else {
      console.dir(tokenResponse, { depth: null, colors: true });
    }
  }
);

기타 샘플

다양한 Azure 패키지를 사용하는 더 많은 코드 샘플을 보려면 Node.js 샘플을 살펴보세요.