I work with Vk.net. I try to do 2 factor authorization. According to the documentation for the place of 5 parameters it is necessary to transfer a variable in text format. Here is an example for the console. In the documentation:

var api = new VkApi(); api.Authorize(new ApiAuthParams { ApplicationId = 123456, Login = "Login", Password = "Password", Settings = Settings.All, TwoFactorAuthorization = () => { Console.WriteLine("Enter Code:"); return Console.ReadLine(); } }); 

I have a winform project. I want to make a form call to enter the code. But I can't do it. I tried this:

 Form3 form = new Form3(); form.Show(); 

I also tried to call a method here,

 private void Hello() { Form3 form = new Form3(); form.Show(); } внутри авторизации вызывал так: TwoFactorAuthorization = () => { Hello(); return DataBank.Text; } 

knocks error:

 System.InvalidOperationException: "Эта операция не поддерживается для относительных URI-адресов." 
  • What is DataBank.Text? - xxxpinktriplesix
  • I created a class of static variables to exchange the necessary data between the forms, while here I used DataBank.Text, I am writing the string value in it, I planned to make a call for 3 forms and write a confirmation code to it. - Valentine Kritenko
  • They helped solve the problem: to the place of 5 parameters where the console call TwoFactorAuthorization = () => {//Console.WriteLine("Enter Code: "); // return Console.ReadLine (); var frm = new EnterCodeForm (); frm.ShowDialog (); return frm.Code; } - Valentine Kritenko

1 answer 1

Helped to solve. In the place of 5 parameter

 TwoFactorAuthorization = () => { //Console.WriteLine("Enter Code:"); //return Console.ReadLine(); var frm = new EnterCodeForm(); frm.ShowDialog(); return frm.Code; } 

Form Code

 public partial class EnterCodeForm: Form { // tbCodeTextBox - компонент типа TextBox, размещенный на диалоговой форме EnterCodeForm public EnterCodeForm() { InitializeComponent(); } public string Code { get { return tbCodeTextBox.Text; }} }