public EmbyUser LogIn(string username, string password, string apiKey, Uri baseUri) { var request = new RestRequest { Resource = "emby/users/authenticatebyname", Method = Method.POST }; var body = new { username, password = StringHasher.GetSha1Hash(password).ToLower(), passwordMd5 = StringHasher.CalcuateMd5Hash(password) }; request.AddJsonBody(body); request.AddHeader("X-Emby-Authorization", $"MediaBrowser Client=\"Ombi\", Device=\"Ombi\", DeviceId=\"{AssemblyHelper.GetProductVersion()}\", Version=\"{AssemblyHelper.GetAssemblyVersion()}\""); AddHeaders(request, apiKey); var policy = RetryHandler.RetryAndWaitPolicy((exception, timespan) => Log.Error(exception, "Exception when calling LogInfor Emby, Retrying {0}", timespan), new[] { TimeSpan.FromSeconds(1) }); var obj = policy.Execute(() => Api.Execute(request, baseUri)); if (obj.StatusCode == HttpStatusCode.Unauthorized) { return(null); } return(JsonConvert.DeserializeObject <EmbyUserLogin>(obj.Content)?.User); }