Authorization error via Login Providers

Good afternoon. Please advise what can be done about this. I use a third-party login provider and for most users everything works fine and they can log in, but for some users this error occurs and I don’t know how to handle it or do anything about it.
A page appears on a white background with the following text:
{"code":3099, "message": "User with identity 'test@iopeninnovations.com' was already registered with another account of this provider", "errorData":{}}

For information, I use only 1 login provider.

Hi @Serhii_Khomenko

It there any chance you run login API being already logged it user?
I mean:

  1. login with userA (user-a@mail.com)
  2. after that, do not logout and the client keeps user-token of the userA
  3. then login with another userB (user-b@mail.com)

Thanks for the answer, I will try to test it now.

Unfortunately, the error was not reproduced. Everything is working fine now. I also noticed a similar behavior with an error when a couple of weeks or days passed, but I did not have time to record whether the error code was the same. I tried to reproduce it by changing the token to the wrong one, it worked fine, returning just that the token status was not valid and the frontend was redirecting to the login page normally.
This error is definitely not the frontend as the error page is in the form of a server error from backendless.
In short, thank you for the answer, I will look into it further, if by chance you know what this behavior may be due to, then let me know.

@Serhii_Khomenko ,

To clarify things:

  1. Does your logic modify oAuthIdentities field directly?
  2. I see in error message test email. Is there a chance that this email is used in several accounts in OAuth2 login provider which you use for login?

Regards, Andriy

Hi Andriy. The email is actually different, I just didn’t want to share it publicly.
But there is a nuance with apps. We have 9 of them, and each of them uses a similar authorization and the same email through the provider’s login. On the provider’s side, the login is also divided into separate projects.

My logic does not change oAuthIdentities directly.

@Serhii_Khomenko ,

The error appears when Backendless user already has different OAuth2 provider account associated with it.
Lets look at example with Twitter. OAuth2 login flow is next:

  1. Obtain user data from Twitter.
  2. Try to find Backendless user using user ID from user data from Twitter.
  3. If there no user found it will try to find existing Backendless user using identity field value. In your case it is an email.
  4. If Backendless user is found by identity value system will try to check if it already has any entries for Twitter already present with other Twitter ID to ensure that there is no data corruption for user in application.
  5. If there is an entry for Twitter with another user ID from Twitter system will throw an error which you received.

On the provider’s side, the login is also divided into separate projects.

If on provider side:

  1. there are different accounts in each project for the same email.
  2. Login provider is integrated with Backendless app using one code for all internal provider projects.
  3. User can freely choose project from which account for login should be used during login to Backendless app.

then there is a chance that you can get such error. User can at first login using projectA with accuont1a then try to login again using projectB with account1b. Emails are the same but IDs in your login provider system are different for these accounts. As result user will get such error.

I hope that this clarified situation a little bit.

Regards, Andriy

Thank you very much for the detailed explanation, Andriy. It clarified the situation a bit, now I will think about its solution in the existing project architecture.