Postman を使って、Azure Active Directory 認証された API のアクセストークンを取得する方法のメモです。
Azure Active Directory にアプリケーションを登録する
Azure Portal で Postman 用の Azure AD アプリケーションを登録します。
必須項目 | 設定値 |
Redirect URIs | https://www.getpostman.com/oauth2/callback |
Client secrets | 自動生成(後から確認できないのでメモしておく) |
API permissions | Postman からアクセスしたい API |
API Permission は、add a permission をクリックして選択できます。忘れずに、Grant admin consent for 既定のディレクトリ
も設定しておきます。
右側に表示される API Permission Name
は、Postman 側の設定で必要なのでメモしておきます。
アプリケーションを登録できたら、Postman 側の設定で必要な情報をメモします。
まずは、Application (client) ID
です。
次に、Endpoints をクリックして表示される2つのエンドポイントです。
OAuth 2.0 authorization endpoint (v2)
OAuth 2.0 token endpoint (v2)
Postman でアクセストークンを取得する
Postman では、Authorization タブから OAuth 2.0
を選択して、Get New Access Token をクリックします。
上記の画面で、それぞれの項目を設定して、Request Token ボタンを押します。
項目 | 設定値 |
Token Names | 任意の名前 |
Auth URL | OAuth 2.0 authorization endpoint (v2) |
Access Token URL | OAuth 2.0 token endpoint (v2) |
Client ID | Application (client) ID |
Client Secret | Client Secrets |
Scope | API Permission Name |
Grant Type | Authorization Code |
取得したアクセストークンを Authorization ヘッダーにセットすれば、Azure Active Directory 認証された API にアクセスできます。