このチュートリアルでは、GAM を使用して
Azure Active Directory でユーザーを認証する方法を説明します。
基本的には、
OAuth 2.0 認証タイプを使用して、Azure Portal と GAM Backend の両方で、いくつかの設定を行う必要があります。
1.アプリケーションを定義して登録します。Microsoft の
こちらのガイドを参照してください。
2.アプリケーション ID を取得します (後に必要):
3.リダイレクト URI を設定します。 [ Authentication ] メニューオプション (面左側のパネル) に移動し、新しい Web プラットフォームを作成します。それから、フォーム内のリダイレクト URI を追加します:
http://<server>:<port>/<BackendBaseURL>/oauth/gam/callback
4. [ Certificates and secrets ] に移動し、新しいシークレットを作成します。シークレットの
値をコピーします (後に必要)。
5. [ API permissions ] で、Microsoft Graph の User.Read を追加したことを確認します:
以下の 2 つの設定オプションがあります:
1.新しい
OAuth 2.0 認証タイプを作成し、次の基本情報を定義します: 名前、デスクリプション、画像 (オプション) など。
2. [ General ] タブで、次を定義します:
リダイレクト URL の形式は次のとおりです:
http://<server>:<port>/<BackendBaseURL>/
注: 次のタブの設定を行うには、Azure でアプリケーションのエンドポイントを確認する必要があります。
3. [ Authorization ] タブ:
URL:
https://login.microsoftonline.com/{tenat}/oauth2/v2.0/authorize
Response type TAG: response_type Value: code
Scope TAG: scope Value: https://graph.microsoft.com/user.read
State TAG: state
Include ClientID and RedirectURL
Response:
Access code TAG: code
Error description TAG: error_description
URL に Azure Active Directory 内のテナントの指定が含まれます。
4. [ Token ] タブ:
URL: https://login.microsoftonline.com/{tenat}/oauth2/v2.0/token
Header Content type: Content-type Value: application/x-www-form-urlencoded
Grant type: grant_type Value: authorization_code
Include = All
Response:
Access token TAG: access_token
Token type TAG: token_type
Expires in TAG: expires_in
Scope TAG: scope
Error description TAG: error_description
Validate external token = False
5. [ User Information ] タブ:
URL: https://graph.microsoft.com/v1.0/me
Method: Get
Header Content type: Content-type Value: application/json;charset=utf-8
Do not include anything
Email TAG: mail
External ID TAG: id
Name TAG: userPrincipalName
First name TAG: givenName
Last name TAG: surname
Error description TAG: message
注:
- [ User Information ] タブでは、上記の設定で指定していないフィールドはすべて空のままにしておきます。
例: 次のエラーを解決する場合: コード: 284、メッセージ:「azuread account is not verified, first verify your azuread account.」
フィールド [ User Verified Email Tag ] が空になっているかどうかを確認します。
- Azure Active Directory へのログインは、Azure Portal ではなく、ご使用のアプリケーションでユーザーの資格情報を入力して実行できます。
そのためには、 [ Redirect to authenticate? ] を無効にします。
エラー GAM 280 AADSTS900144 の場合: リクエスト本体に次のパラメーターが含まれている必要があります: 'scope'。SAC 51934 を参照してください。