Hi Shopify Community,
I’m working with a Shopify Remix app. When a store installs the app, I want to generate a custom token using JWT and store it along with the store’s name and associated email in a Prisma database table. What are the main steps to implement this?
Hi @Sneha_Subhash ,
Main steps to implement Prisma database table :-
-
Define Prisma model
Create a Store model with fields: shop, email, and token.
-
Install JWT library
npm install jsonwebtoken
-
Create JWT utility
Write a function to generate a JWT token using the store’s shop name.
-
Handle Shopify OAuth callback
In your callback route:
Extract shop and access_token.
Use the token to fetch the store’s email from the Shopify Admin API.
Generate a JWT using the shop.
Store shop, email, and the JWT in the database via prisma.store.upsert().
- Secure and verify
Store JWT_SECRET in .env.
Use the JWT to authenticate future requests from the store.
Implement these steps and let me know if you need further assistance .
Thanks !
1 Like