Logging in directly to the backend

Hi,
We have a Wix website that users register and login to talk to other users, purchase items etc. We are also writing an app for iOS and Android and would like to be able to access the users data by writing backend code.
What I can’t find is how to log the user in directly from the app! Is it possible or should I be using a different approach?

John

Hey
You can’t log the user in into your system using backend code because the Wix Users library is not usuable in backend code what I have found out.

What is your goal from the app?

I use a web page inside apps to make the user login and then I get back the users contact ID and I store that and then I use that in backend queries when querying their data, _owner = contactId will work even in backend code.

I seem to have missed getting back the contactID, I had thought I could use a web page in the app for the login but wasn’t sure how to get back anything useful.

John

@jjs If you do your own login page using Wix Code you can use a session token from the app, store that in a Data Collection, send that session token to the login page using a query like ?sessionToken=AND THE TOKEN HERE and then when the user is logged in store their contact ID in the data collection in the record which have your session token and then close or redirect the page and through the http-functions get the session token and the contact Id, voila

1 Like

@andreas-kviby Brilliant. Thanks very much!

1 Like

@jjs No problems, please mark my answer as top comment if you want. It helps me.