标签:ada turn 解决 ken client document array readline main
解决方案
static void Main(string[] args) { Console.WriteLine("确定三个项目都已经启动"); Console.Read(); Console.WriteLine("按任意键开始运行"); Task.Run(async () => { // discover endpoints from metadata var client = new HttpClient(); var disco = await client.GetDiscoveryDocumentAsync("http://localhost:5000"); if (disco.IsError) { Console.WriteLine(disco.Error); return; } }); Console.ReadLine(); Console.ReadKey(false);//因为控制台会关闭,设置不关闭 }
换种方式执行
static void Main(string[] args) { Console.WriteLine("确定三个项目都已经启动"); Console.Read(); Console.WriteLine("按任意键开始运行"); // discover endpoints from metadata var client = new HttpClient(); var disco = client.GetDiscoveryDocumentAsync("http://localhost:5000").ConfigureAwait(false).GetAwaiter().GetResult(); if (disco.IsError) { Console.WriteLine(disco.Error); return; } Console.ReadKey(false);//因为控制台会关闭,设置不关闭 }
static void Main(string[] args) { Console.WriteLine("确定三个项目都已经启动"); Console.Read(); Console.WriteLine("按任意键开始运行"); // discover endpoints from metadata var client = new HttpClient(); var disco = client.GetDiscoveryDocumentAsync("http://localhost:5000").ConfigureAwait(false).GetAwaiter().GetResult(); if (disco.IsError) { Console.WriteLine(disco.Error); return; } // request token var tokenResponse = client.RequestClientCredentialsTokenAsync(new ClientCredentialsTokenRequest { Address = disco.TokenEndpoint, ClientId = "socialnetwork", ClientSecret = "secret", Scope = "socialnetwork" }).ConfigureAwait(false).GetAwaiter().GetResult(); // call api client.SetBearerToken(tokenResponse.AccessToken); var response = client.GetAsync("http://localhost:5001/identity").ConfigureAwait(false).GetAwaiter().GetResult(); if (!response.IsSuccessStatusCode) { Console.WriteLine(response.StatusCode); } else { var content = response.Content.ReadAsStringAsync().ConfigureAwait(false).GetAwaiter().GetResult(); Console.WriteLine(JArray.Parse(content)); } Console.ReadKey(false);//因为控制台会关闭,设置不关闭 }
客户端==应用程序的身份标识-》是否可以访问
标签:ada turn 解决 ken client document array readline main
原文地址:https://www.cnblogs.com/fger/p/11044548.html