How can cnotact log in with two accounts in one app?

Using a library VK.NET.

Using the Function LoginIn autorisoes.
private void LoginIn(VkApi vk, string login, string password)
{
 vk.Authorize(new ApiAuthParams
{
 ApplicationId = AppID,
 Login = Login,
 Password = password,
 Settings = Settings.All
});
 }


The problem is that after login the second account appears VkApiAuthorizationException exception(wrong username or password). In fact, the pair login the password is correct. The exception only occurs when authorizing a second account regardless of the login and password.

The whole code:
public partial class MainWindow : Window
{
 public MainWindow()
{
InitializeComponent();
}

 private vk1 VkApi = new VkApi(), vk2 = new VkApi();

 #region logins
 private void LoginIn(VkApi vk, string login, string password)
{
 vk.Authorize(new ApiAuthParams
{
 ApplicationId = 5427437,
 Login = Login,
 Password = password,
 Settings = Settings.All
});
}

 private void CheckBox1_Checked(object sender, RoutedEventArgs e)
{
 LoginIn(vk1, Login1.Text, Password1.Text);
}

 private void Button_Click(object sender, RoutedEventArgs e)
{
vk1.Status.Set("1");
vk2.Status.Set("2");
}

 private void CheckBox2_Checked(object sender, RoutedEventArgs e)
{
 LoginIn(vk2, Login2.Text, Password2.Text);
}
#endregion
 }
July 9th 19 at 13:20
2 answers
July 9th 19 at 13:22
Solution
The source code libraries are on github, why not to look into the implementation and not to polarcat information about native (REST) API VK?
if (!authorization.IsAuthorized)
{
 throw new VkApiAuthorizationException("Invalid authorization with {0} - {1}", emailOrPhone, password);
}
...
public bool IsAuthorized => !string.IsNullOrWhiteSpace(AccessToken);
....
private string AccessToken
{ get; set; }

You use different instances VkApi?
Yes, different. - verna.Adams commented on July 9th 19 at 13:25
: All the code - in the Studio! - Elna.Volkman92 commented on July 9th 19 at 13:28
: added. - verna.Adams commented on July 9th 19 at 13:31
try to make a delay of 5 seconds between authorizations. - Elna.Volkman92 commented on July 9th 19 at 13:34
not help. - verna.Adams commented on July 9th 19 at 13:37
: Try to run two instances of the program authorization. If possible, I need to crawl through the code (libraries) to search static-fields and other singletons. - Elna.Volkman92 commented on July 9th 19 at 13:40
not work. Created two instances of the Browser. Made authorization through the Browser.Authorize. Only the first authenticated account. - verna.Adams commented on July 9th 19 at 13:43
: Then it's most likely limitations of the native API. Humble. - Elna.Volkman92 commented on July 9th 19 at 13:46
: katemobile like to have the option to use multiple accounts. - verna.Adams commented on July 9th 19 at 13:49
: To understand the limitation. Collect from source library, predebate the place where falling off and the like. Try to connect to the native API manually.

PS Say katemobile built on this SDK: https://github.com/thest1/Android-VKontakte-SDK the scoop there. - Elna.Volkman92 commented on July 9th 19 at 13:52
: Thank you. - verna.Adams commented on July 9th 19 at 13:55
July 9th 19 at 13:24
Create an array of objects that will store the object each object in this library VK.NET (authorized)
I have two of them. Pass one object into the first parameter of the method. Tried to make authorization without a method, but it gave no changes. - verna.Adams commented on July 9th 19 at 13:27

Find more questions by tags C#VKontakte