show an error page when galtinn returns no access token

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
leanderandClaude Opus 5.5 committed 2026-10-23 02:48:59 +02:00
1 parent 30558eaa45
commit 2b5abc14d8
1 file changed
+11 -1
+11 -1
View File
@@ -94,10 +94,20 @@ async def callback(request: Request, code: str, state: str):
)
token_data = await r.json()
if not (access_token := token_data.get("access_token")):
return templates.TemplateResponse(
"error.html",
{
"request": request,
"message": "Galtinn svarte uten autentiseringsnøkkel!",
},
status_code=502,
)
# Get user info from galtinn
async with session.get(
f"{GALTINN_API_URL}/oauth/userinfo/",
headers={"Authorization": f"Bearer {token_data['access_token']}"},
headers={"Authorization": f"Bearer {access_token}"},
) as r:
if r.status != 200:
return templates.TemplateResponse(