private async void btnLoginNew_Click(object sender, EventArgs e) { var code = tbVerficationCode.Text; // you can change code in debugger too if (String.IsNullOrWhiteSpace(code)) { throw new Exception("CodeToAuthenticate is empty in the app.config file, fill it with the code you just got now by SMS/Telegram"); } TLUser user = null; try { user = await client.MakeAuthAsync(tbPhoneNumber.Text, hash, code); } catch (CloudPasswordNeededException ex) { var password = await client.GetPasswordSetting(); var password_str = TxtPassword.Text; user = await client.MakeAuthWithPasswordAsync(password, password_str); } catch (InvalidPhoneCodeException ex) { throw new Exception("CodeToAuthenticate is wrong in the app.config file, fill it with the code you just got now by SMS/Telegram", ex); } try { var photo = ((TLUserProfilePhoto)user.photo); var photoLocation = (TLFileLocation)photo.photo_small; var resFile = await client.GetFile(new TLInputFileLocation() { local_id = photoLocation.local_id, secret = photoLocation.secret, volume_id = photoLocation.volume_id }, 100000, 0); Bitmap image; using (MemoryStream stream = new MemoryStream(resFile.bytes)) { image = new Bitmap(stream); } pbSelfPicture.Image = image; } catch (Exception) { } }