Skip to content
Snippets Groups Projects

MFE-6 Use Redis to cache SAP responses

Merged Trond Aasan requested to merge MFE-6-caching into master
Files
10
import json
import logging
from datetime import datetime, timedelta
from http import HTTPStatus
from typing import Callable, Optional, List, Iterable, Tuple
from urllib.parse import urlencode
@@ -184,7 +185,7 @@ def routes(config: MFEConfig, app: FastAPI, home: Callable):
config.auth.dataporten.client_secret,
),
)
if token_response.status_code == 400:
if token_response.status_code == HTTPStatus.BAD_REQUEST:
logger.error(
"Got 400 Bad Request. Check configuration: %s", token_response.content
)
@@ -192,7 +193,9 @@ def routes(config: MFEConfig, app: FastAPI, home: Callable):
token_response.raise_for_status()
if not token_response:
raise HTTPException(500, "Failed to get access token")
raise HTTPException(
HTTPStatus.INTERNAL_SERVER_ERROR, "Failed to get access token"
)
oauth_token = auth_client.parse_request_body_response(
json.dumps(token_response.json())
Loading