applySessionToken is not a function ERROR?

Hi, here’s my flow and the problem I’m having:

  1. User comes to site, tries to login, sees a TypeForm form (typeform.com)

  2. Upon completion of the TypeForm, TypeForm calls a webhook by doing a POST to a function I have in http-functions.js on Wix

  3. Inside that function, I parse the JSON payload from TypeForm and create a temporary password for the user

  4. I email the user with his/her temp password

So far so good; all of this works.

(Please don’t ask me to change my login setup; I NEED this kind of flow.)

However, I also want to log in the user right away, to remove friction.

So I created another backend login function, which seems to work. I pass it the email and password, and that function returns a promise string. I copied that code from here: https://www.wix.com/corvid/reference/wix-users-backend/login

Then, in my front-end http-functions.js, I have code that calls that backend function and tries to apply the sessionToken. I copied that code from here:
https://www.wix.com/corvid/reference/wix-users/applysessiontoken

I’m handling the error, and this is what I’m getting, after calling wixUsers.applySessionToken(result.sessionToken):

TypeError: _wixUsersBackend2.default.applySessionToken is not a function

Any thoughts/help would be greatly appreciated. Thanks.

Here is the JSON payload in the Wix console. Thanks for your help with this.

“jsonPayload”: {

“message”: “[“error applying session token :frowning: - TypeError: _wixUsersBackend2.default.applySessionToken is not a function”]”
}

Seems like you are using the applySessionToken() from a backend file, that function is only for the frontend i.e. website page