シングルページ アプリケーション:コード構成

ご利用のシングルページ アプリケーション (SPA) のコードを構成する方法について説明します。

シングルページ アプリをサポートする Microsoft ライブラリ

次の Microsoft ライブラリはシングルページ アプリをサポートしています。

言語/フレームワーク プロジェクト
GitHub
Package 取得
started
ユーザーのサインイン Web API へのアクセス 一般提供 (GA) または
パブリック プレビュー1
Angular MSAL Angular v22 msal-angular チュートリアル Library can request ID tokens for user sign-in. Library can request access tokens for protected web APIs. GA
Angular MSAL Angular3 msal-angular Library can request ID tokens for user sign-in. Library can request access tokens for protected web APIs. GA
AngularJS MSAL AngularJS3 msal-angularjs Library can request ID tokens for user sign-in. Library can request access tokens for protected web APIs. パブリック プレビュー
JavaScript MSAL.js v22 msal-browser チュートリアル Library can request ID tokens for user sign-in. Library can request access tokens for protected web APIs. GA
JavaScript MSAL.js 1.03 msal-core Library can request ID tokens for user sign-in. Library can request access tokens for protected web APIs. GA
React MSAL React2 msal-react チュートリアル Library can request ID tokens for user sign-in. Library can request access tokens for protected web APIs. GA

1オンライン サービスのユニバーサル ライセンス条項は、パブリック プレビューのライブラリに適用されます。

2PCKE のみを使用した認証コード フロー (推奨)。

3暗黙的な許可のフローのみ。

アプリケーションのコード構成

MSAL ライブラリでは、ライブラリの初期化中にアプリケーションの登録情報が構成として渡されます。

import * as Msal from "@azure/msal-browser"; // if using CDN, 'Msal' will be available in global scope

// Configuration object constructed.
const config = {
    auth: {
        clientId: 'your_client_id'
    }
};

// create PublicClientApplication instance
const publicClientApplication = new Msal.PublicClientApplication(config);

構成可能なオプションの詳細については、MSAL.js を使用したアプリケーションの初期化に関する記事を参照してください。

次のステップ

このシナリオの次の記事であるサインインとサインアウトに関する記事に進みます。