Sandarualoka / Trendy-E-commerce

0 stars 0 forks source link

jwt token #1

Open Sandarualoka opened 3 weeks ago

Sandarualoka commented 3 weeks ago

how i can crate the jwt token for the project

Thameera08 commented 3 weeks 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)