We are only using backend sdk , no sdk on fronten...
# community
y
We are only using backend sdk , no sdk on frontend Using
Passwordless.consumeCode
I am getting below response -
Copy code
{
  status: 'OK',
  createdNewUser: true,
  user: {
    phoneNumber: '+919644683149',
    id: '32b3547d-395f-47b7-8946-c818aa56f4aa',
    timeJoined: 1649160487992
  }
}
Now i have
user.id
, so on backend only how can we retrieve user accessToken / JWT token using
user.id
r
So you have two options: - use the frontend SDK along with our session recipe. Using the session recipe, you can create a new session
Session.createNewSession(res, userId)
and this will attach access / refresh tokens to the cookies and work along with the frontend SDK to maintain a secure session. - use the JWT recipe to create a JWT using the userId above which you can send to the frontend and then verify that on your backend. This would work, but is less powerful and secure than the first method.
Any reason for you not to use our frontend SDK?
y
as of now testing it out for backend , changing things on frontend will take time
r
ah ok
y
so i want to use JWT recipe
r
Yea
y
previously using AUTH0 so replacing backend only
r
okay
You can see the functions from the recipe here: https://supertokens.com/docs/nodejs/modules/recipe_jwt.html
y
createJWT(input: { payload?: any; userContext: any; validitySeconds?: number }): so for user.id whats the input parameter here
r
you can do:
Copy code
createJWT({sub: userId}, ...);
2 Views