Sandarualoka / Trendy-E-commerce

0 stars 0 forks source link

jwt token #1

Open Sandarualoka opened 5 days ago

Sandarualoka commented 5 days ago

how i can crate the jwt token for the project

Thameera08 commented 5 days ago

import jwt import datetime

Define your secret key and data

secret_key = "your_secret_key" payload = { "user_id": 123, "username": "exampleuser", "exp": datetime.datetime.utcnow() + datetime.timedelta(hours=1) # Token expiration }

Encode the token

token = jwt.encode(payload, secret_key, algorithm="HS256") print("JWT Token:", token)