static async Task Main(string[] args) { Console.WriteLine("Request Token"); var creds = new [] { new { Name = "CapWeb", Secret = "7v0ehQkQOsWuzx9bT7hcQludASvUFcD5l5JEdkNDPaM", Url = "https://localhost:5010/Home/MyAccess" } }; var cred = creds[0]; var holder = CapWebTokenFactory.CreateCapWebClient(cred.Name, cred.Secret); await AttemptLogin(holder); var client = holder.AuthenticatedClient(); Console.WriteLine("Access Response: [" + await(await client.GetAsync(cred.Url)).Content.ReadAsStringAsync() + "]" ); Console.WriteLine("Done"); }
public HubLogConnection(TargetSite site) { connection = new HubConnectionBuilder() .WithUrl(site.Url.TrimEnd('/', '\\') + "/MelvilleSpecialLoggingHubWellKnownUrl", o => o.AccessTokenProvider = GetAccessToken) .WithAutomaticReconnect() .Build(); disposeToStopReadingEvents = connection.On("SendEvent", (Action <string>)HandleLogEvent); if (site.Secret.Length > 0) { token = CapWebTokenFactory.CreateCapWebClient(site.Name, site.Secret); } connection.StartAsync(); }