ノードでこれを行う方法に関するサンプルはありませんが、おそらくC#のソリューションが役に立ちますか?
これを行う方法は、Activity
オブジェクトからコントローラに入ってくるentities
コレクションを調べることです。これはの一部であり、毎回リクエストをボットに送信するので、いつでも実行できます。
entities
コレクションの内部では、CortanaはConnected Serviceの認証フローから生じたトークンを含むauthorization
エントリを配置します。 Connected Serviceを使用してMicrosoftサービス(ライブ、MSAなどにログインする)にヒットしている場合は、このトークンを回して、Microsoft Graphからユーザーに関する情報を要求できます。助け
// auth token from cortana's connected service stored as Entity object of type 'authorization' with child property 'token' holding the actual value
var token = activity.Entities.Single(e => e.Type == @"authorization").Properties.Value<string>(@"token");
using (var client = new HttpClient())
{
// The token can be used to query the Graph, but only because we know that it is from MS Identity. We couldn't query the Graph like this if we were using our own Identity provider (eg: Contoso Identity)
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(@"Bearer", token);
try
{
var response = await client.GetAsync(@"https://graph.microsoft.com/v1.0/me").ConfigureAwait(false);
if (response.IsSuccessStatusCode)
{
var resultString = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
/* Response from /me looks like:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users/$entity",
"givenName": "Brandon",
"surname": "H",
"displayName": "Brandon H",
"id": "<unique user id!>",
"userPrincipalName": "<E-MAIL ADDRESS!!>",
"businessPhones": [],
"jobTitle": null,
"mail": null,
"mobilePhone": null,
"officeLocation": null,
"preferredLanguage": null
}
*/
}
}
catch { }
}
希望:C#ので
、それはこのようになります!グラフのさまざまなテナントから返ってきたものを試してみたい場合は、Graph Explorerがこれを行うのに最適です。
node.jsの例については、この例では古くなっているものを明確にすることはできますか? –
これはAzure ADで動作していますか?ニース。私はConnected Serviceスクリーンの右側のボックスに記入するのに適切なものを見つけることができないようです - Azure ADアプリケーション登録のどの設定がCortana Connectedのどこに行ったかでbluredスクリーンショットなどを投稿する可能性がありますサービス画面? –