import jwt from jwt import PyJWTError from fastapi import HTTPException from Utils.Authentication import Config def decode_token(token: str): try: payload = jwt.decode(token, Config.SECRET_KEY, algorithms=[Config.ALGORITHM]) except jwt.exceptions.ExpiredSignatureError: raise HTTPException(status_code=401, detail="Token Has Expired") except PyJWTError: raise HTTPException(status_code=401, detail="Invalid Token") return payload