Support Topics Documentation Slack YouTube Blog

User token confusion on upgrading backendless 3.x to backendless 5.x

Hi Guys

I have upgraded an app from v3 to v5 backend.

Users who have never been logged in the past seem to be exempt, but I think users who have used the old app in the past which was running on the backendless 3 and now who download the new app running on version 5 backendless are having trouble when they sign in.

I ‘think’ the problem is to do with user tokens, we are getting this error in testing: Not existing user token - Relogin user to update your user token

How should we handle this. They can’t logout and relogin because the app already thinks they are logged in so doesn’t show this option.

Is there anything you can think of to solve this without changing any code or requiring an app update. New users who have never used the app in the past seem to be unaffected.

Regards

Mike

Please, give your App Id

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

As far as I understand your application doesn’t allow you to just log out and enter the application, I can advise you to just try to remove the device tocken on the test application

Hi

Sorry I don’t quite understand what you mean. How do I remove the device token from the application?

Can you elaborate a little more please.

You can add button exit and login in your app

Hi @mike-turner, you could use the following API to validate the user token:
https://backendless.com/docs/ios/users_login.html#validating-user-login

If the token happens to be invalid, you can redirect the user to the login screen. This function would be useful for both “classes” of users - the ones who used the old app and the new one.

Regards,
Mark

Thanks Mark.

If the token is invalid should I call user.logout() before redirecting the user to the login screen?

Mike

Is it possible to simulate giving a user an invalid token - so that I can test this scenario?

See the following topic:

Ah interesting, but I can’t see how to do this in Java/Android?

To do this in Android SDK you’d use the following code:

HeadersManager.getInstance().addHeader( HeadersManager.HeadersEnum.USER_TOKEN_KEY, userToken );

Thanks Mark,

App ID: E9DF3457-FBDF-4D42-A6F3-FDFF2C260FF6

We are still really struggling here with users logging in. I can’t actually figure out what is going on - I still think it is something to do with migration causing some sort of confusion. We never had this once on the backendless v3 code. I have checked all the new code and can’t see anything wrong. I can login absolutely no problem on my test device but we have had lots of complaints from new users saying they cannot login. Especially on Android devices, but this may be coincidence.

Anyway with a chat with a particularly helpful user we got this. hopefully it might give a clue… This was from an Android app.

ME: Try logging in.
RESULT: it seems to register that this is a valid user but it looks like it is timing out and crashing our app: (never happened before)

ME: Please try one more time:

RESULT: error returned: unable to resolve host ‘api.backendless.com

OK weird, never seen that before:

ME: Can you try logging in on the website?
RESULT: successful login.

ME: OK good try again on the app:
RESULT: This time we get: Unable to login: Multiple login limit for the same user account has been reached:

We can’t clear this error!! How can we clear this through console.

I followed this link, Way to log out users? but it didn’t clear the login error for this user.

Please help!

Mike

Whenever a user logs in with the same credentials more than once, a multiple login logic is triggered. There is a limit for multiple logins in your app in Backendless. You can see it on the Users > Login section in Backendless console. In order to avoid a situation when you run into this limit, it is recommended to clear out user tokens by calling the logout API whenever a user quits or shuts down the app or even before executing the login API.

As for the error with the hostname, this would be outside of our control - there must be something with the mobile network and the provider not resolving the domain name.

Regards,
Mark

As

Hi Mark - we do actually call the user logout API if there is a problem when the user logins and this has worked in the past. However this afternoon it wasn’t working and wasn’t clearing the problem. And also normally if we toggle the multiple login button on the console this has the effect to reset the limit. None of this was making any effect, however I have just tried again and it does seem to be working again? I have managed to reset the limit. Very strange!