From f09758606d806faac3a6cc453a7b1b7e5e1a9410 Mon Sep 17 00:00:00 2001 From: Vadim Melnik Date: Thu, 19 Oct 2023 00:19:55 +0300 Subject: [PATCH] Fixed wraning: "DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version". --- repromon_app/security.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repromon_app/security.py b/repromon_app/security.py index bbd5fa2..4c444ee 100644 --- a/repromon_app/security.py +++ b/repromon_app/security.py @@ -3,7 +3,7 @@ import hashlib import logging import uuid -from datetime import datetime, timedelta +from datetime import datetime, timedelta, timezone from typing import Annotated from fastapi import Depends, HTTPException, Request, status @@ -166,7 +166,7 @@ def create_access_token(self, username: str, expire_sec: int = -1) -> str: expire_sec = app_settings().TOKEN_EXPIRE_SEC if username and len(username) > 0: expire: datetime.datetime = \ - datetime.utcnow() + timedelta(seconds=expire_sec) + datetime.now(timezone.utc) + timedelta(seconds=expire_sec) data = { "sub": username, "exp": expire