Skip to content

Commit

Permalink
Simplify access token creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Iain-S committed May 23, 2024
1 parent e9e2e28 commit abd9f8f
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions status_function/status/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
value is 5.
"""
from datetime import datetime, timedelta
from typing import Any

import jwt
import requests
Expand Down Expand Up @@ -54,12 +53,9 @@ def create_access_token(self) -> str:
Returns:
The access token.
"""
token_claims: dict[str, Any] = {"sub": "status-app"}
access_token_expires = timedelta(minutes=ACCESS_TOKEN_EXPIRE_MINUTES)

expire = datetime.utcnow() + access_token_expires
token_claims.update({"exp": expire})

token_claims = {"sub": "status-app", "exp": expire}
return jwt.encode(token_claims, self.private_key, algorithm=ALGORITHM)

def __call__(self, r: requests.PreparedRequest) -> requests.PreparedRequest:
Expand Down

0 comments on commit abd9f8f

Please sign in to comment.