private static async Task <HttpMessageHandler> CreateTokenHandler(string authority, string username, string password, string clientId, string scope) { var automation = new BrowserAutomation(username, password); var browser = new Browser(automation); var options = new OidcClientOptions { Authority = authority, ClientId = clientId, RedirectUri = $"http://127.0.0.1:{browser.Port}", Scope = scope, FilterClaims = false, Browser = browser, Policy = new Policy { Discovery = new DiscoveryPolicy { ValidateIssuerName = false } } }; var oidcClient = new OidcClient(options); var result = await oidcClient.LoginAsync(new LoginRequest()).ConfigureAwait(false); return(new TokenHandler(result.AccessToken)); }
public Browser(BrowserAutomation automation, int?port = null, string path = null) { this.automation = automation; this.path = path; this.Port = port ?? GetRandomUnusedPort(); }