Esempio n. 1
0
        public async Task RunAsync()
        {
            while (true)
            {
                using var activity = new Activity(nameof(RunAsync)).Start();
                try
                {
                    Console.WriteLine("トークンを取得し、APIを呼びだします。");
                    Console.ReadKey();

                    var response = await _tokenClient.RequestTokenAsync(
                        new TokenSettings { AuthorityBaseUri = Constants.Authority.BaseUri },
                        Constants.ConsoleApp.ClientId,
                        Constants.ConsoleApp.ClientSecret,
                        new[] { Constants.Bff.ResourceName });

                    response.DumpConsole();

                    var data = await _bffClient.GetServiceUsersAsync(response.AccessToken);

                    Console.WriteLine(JsonConvert.SerializeObject(data));
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
                finally
                {
                    activity.Stop();
                }
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> Secret()
        {
            var token = await _tokenClient.RequestTokenAsync(new TokenSettings { AuthorityBaseUri = Constants.Authority.BaseUri },
                                                             Constants.WebApp.ClientId,
                                                             Constants.WebApp.ClientSecret,
                                                             new[]
            {
                Constants.Bff.ResourceName
            });

            var result = await _bffClient.GetServiceUsersAsync(token.AccessToken);

            var json = JsonConvert.SerializeObject(result.ApiUser);

            ViewBag.ApiUser = json;
            return(View());
        }