Beispiel #1
0
        private async Task <HttpMessageHandler> CreateTokenHandler()
        {
            var automation = new BrowserAutomation(this.configuration.GetValue <string>("username"), this.configuration.GetValue <string>("password"));
            var browser    = new Browser(automation);
            var options    = new OidcClientOptions
            {
                Authority    = this.Authority,
                ClientId     = this.configuration.GetValue <string>("clientId"),
                RedirectUri  = $"http://127.0.0.1:{browser.Port}",
                Scope        = this.configuration.GetValue <string>("scope"),
                FilterClaims = false,
                Browser      = browser,
            };

            var oidcClient = new OidcClient(options);
            var result     = await oidcClient.LoginAsync(new LoginRequest()).ConfigureAwait(false);

            return(new TokenHandler(result.AccessToken));
        }
Beispiel #2
0
 public Browser(BrowserAutomation automation, int?port = null, string path = null)
 {
     this.automation = automation;
     this.path       = path;
     this.Port       = port ?? GetRandomUnusedPort();
 }