Beispiel #1
0
        private static async Task Login()
        {
            var    browser     = new SystemBrowser(45656);
            string redirectUri = "https://127.0.0.1:45656";

            var options = new OidcClientOptions
            {
                Authority    = _authority,
                ClientId     = "native.code",
                RedirectUri  = redirectUri,
                Scope        = "openid profile native_api",
                FilterClaims = false,
                Browser      = browser,
                Flow         = OidcClientOptions.AuthenticationFlow.AuthorizationCode,
                ResponseMode = OidcClientOptions.AuthorizeResponseMode.Redirect,
                LoadProfile  = true
            };

            var serilog = new LoggerConfiguration()
                          .MinimumLevel.Verbose()
                          .Enrich.FromLogContext()
                          .WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message}{NewLine}{Exception}{NewLine}")
                          .CreateLogger();

            options.LoggerFactory.AddSerilog(serilog);

            _oidcClient = new OidcClient(options);
            var result = await _oidcClient.LoginAsync(new LoginRequest());

            ShowResult(result);
            await NextSteps(result);
        }
        private static async Task Login()
        {
            var    browser     = new SystemBrowser(45656);
            string redirectUri = "http://127.0.0.1:45656";

            var options = new OidcClientOptions
            {
                Authority    = _authority,
                ClientId     = _clientId,
                RedirectUri  = redirectUri,
                Scope        = "openid profile",
                FilterClaims = false,
                Browser      = browser,
                Flow         = OidcClientOptions.AuthenticationFlow.AuthorizationCode,
                ResponseMode = OidcClientOptions.AuthorizeResponseMode.Redirect,
                LoadProfile  = true
            };

            options.Policy.Discovery.ValidateIssuerName = false;
            options.Policy.Discovery.ValidateEndpoints  = false;
            var serilog = new LoggerConfiguration()
                          .MinimumLevel.Verbose()
                          .Enrich.FromLogContext()
                          .WriteTo.LiterateConsole(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message}{NewLine}{Exception}{NewLine}")
                          .CreateLogger();

            options.LoggerFactory.AddSerilog(serilog);

            _oidcClient = new OidcClient(options);

            Dictionary <string, string> extra = new Dictionary <string, string>
            {
                ["mine_data"] = Guid.NewGuid().ToString()
            };

            //   ResponseValidationResult rvr = null;
            var result = await _oidcClient.LoginAsync(new LoginRequest()
            {
                FrontChannelExtraParameters = extra
            });

            ShowResult(result);
        }