公式な取得方法
公式な方法は下記の通りです。
Azure Portalにログインするか、PowerShellを使う必要があります。
Office 365 テナント ID を検索する
上記手順が面倒な僕みたいな人
下記のMSのエンドポイントにリクエストを送ることで、tenantID等を取得することができます。
https://login.windows.net/${domain}/.well-known/openid-configuration
nodejsでスクリプトも書いてみました。標準ライブラリだけで動作するはず。
"use strict";
const https = require("https");
if(process.argv.length !== 3){
console.log("domain name should be specified");
process.exit(1);
}
const domain = process.argv[2];
https.get({
hostname: 'login.windows.net',
port: 443,
path: `/${domain}/.well-known/openid-configuration`,
agent: false
}, (res) => {
let body = '';
res.setEncoding('utf8');
res.on('data', (chunk) => {
body += chunk;
});
res.on('end', (res) => {
res = JSON.parse(body);
if(res.error){
console.log(res.error_description);
process.exit(1);
}
const issuer = res.issuer;
const tenantId = issuer.replace("https://sts.windows.net/","").replace("/","");
console.log(tenantId);
});
});
Webサービスにドメイン名を渡しても抵抗がない人
一発で検索してくれるサービスがあります。
僕とは全然関係ないサイトですし、取得方法も上記とは異なる可能性があります。
What is your domain name