/// <summary> /// Run the sample. /// </summary> /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> public async Task RunAsync() { var validServer = false; do { // Prompt for server url. // Url must be proto://host/path // ex: https://demo.jellyfin.org/stable Console.Write("Server Url: "); var host = Console.ReadLine(); _sdkClientSettings.BaseUrl = host; try { // Get public system info to verify that the url points to a Jellyfin server. var systemInfo = await _systemClient.GetPublicSystemInfoAsync() .ConfigureAwait(false); validServer = true; Console.WriteLine($"Connected to {host}"); Console.WriteLine($"Server Name: {systemInfo.ServerName}"); Console.WriteLine($"Server Version: {systemInfo.Version}"); } catch (InvalidOperationException ex) { Console.Error.WriteLine("Invalid url"); Console.Error.WriteLine(ex); } catch (SystemException ex) { Console.Error.WriteLine($"Error connecting to {host}"); Console.Error.WriteLine(ex); } }while (!validServer); var validUser = false; UserDto userDto = null !; do { try { Console.Write("Username: "******"Password: "******"Logging into {_sdkClientSettings.BaseUrl}"); // Authenticate user. var authenticationResult = await _userClient.AuthenticateUserByNameAsync(new AuthenticateUserByName { Username = username, Pw = password }) .ConfigureAwait(false); _sdkClientSettings.AccessToken = authenticationResult.AccessToken; userDto = authenticationResult.User; Console.WriteLine("Authentication success."); Console.WriteLine($"Welcome to Jellyfin - {userDto.Name}"); validUser = true; } catch (UserException ex) { Console.Error.WriteLine("Error authenticating."); Console.Error.WriteLine(ex); } }while (!validUser); await PrintViews(userDto.Id) .ConfigureAwait(false); }