public static Task <bool> AuthenticateAsync(HttpClient httpClient, RocketChatClientAuthentication auth) { httpClient.BaseAddress = new Uri(auth.BaseUrl.EnsureEndsWith('/')); httpClient.DefaultRequestHeaders.Add("X-User-ID", auth.UserId); httpClient.DefaultRequestHeaders.Add("X-Auth-Token", auth.AuthToken); return(Task.FromResult(true)); }
public void AddTokenRegistration(RocketChatClientAuthentication auth) { var key = RocketChatClientAuthentication.CalculateCacheKey(auth.BaseUrl, auth.Username); if (!authenticationMap.ContainsKey(key)) { authenticationMap.Add(key, auth); } }
public async Task SetUserPresenceAsync(RocketChatClientAuthentication auth, string status, string message) { using (var client = HttpClientFactory.CreateClient("RocketChat")) { await RocketChatAuthenticationHelper.AuthenticateAsync(client, auth); _ = await client.PostAsJsonAsync("api/v1/users.setStatus", new { message = message, status = status }); } }
// TODO: Refactor this out of the authenticator public async Task SignOffAsync(RocketChatClientAuthentication auth) { await SetUserPresenceAsync(auth, "offline", "404 not found"); }