https://supertokens.com/ logo
#community
Title
# community
y

yyogeshwar

04/05/2022, 2:21 PM
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

rp

04/05/2022, 2:23 PM
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

yyogeshwar

04/05/2022, 2:24 PM
as of now testing it out for backend , changing things on frontend will take time
r

rp

04/05/2022, 2:24 PM
ah ok
y

yyogeshwar

04/05/2022, 2:24 PM
so i want to use JWT recipe
r

rp

04/05/2022, 2:24 PM
Yea
y

yyogeshwar

04/05/2022, 2:24 PM
previously using AUTH0 so replacing backend only
r

rp

04/05/2022, 2:24 PM
okay
You can see the functions from the recipe here: https://supertokens.com/docs/nodejs/modules/recipe_jwt.html
y

yyogeshwar

04/05/2022, 2:26 PM
createJWT(input: { payload?: any; userContext: any; validitySeconds?: number }): so for user.id whats the input parameter here
r

rp

04/05/2022, 2:27 PM
you can do:
Copy code
createJWT({sub: userId}, ...);
2 Views