Ich sende meine Aktualisierungs- und Zugangs-Token als HTTP-Cookies an die Frontend meiner nächsten J-Anwendung. Aber sie werden nicht zum Browser hinzugefügt.
Ich sende meine Aktualisierungs- und Zugangs-Token als HTTP-Cookies an die Frontend meiner nächsten J-Anwendung. Aber sie werden nicht zum Browser hinzugefügt.[code]origins = [ config.FRONTEND_ORIGIN ]
# Set HTTP-only cookies in the response response.set_cookie( key="refresh_token", value=tokens.refresh_token, httponly=True, max_age=7 * 24 * 60 * 60, # 7 days secure=False, # Only set to True in production samesite="none", )
response.set_cookie( key="access_token", value=f"Bearer {tokens.access_token}", httponly=True, max_age=15 * 60, # 15 minutes secure=False, # Only set to True in production samesite="none" )
return { "success": True, "message": "Login successful" } except UnauthorizedException as e: raise HTTPException( status_code=status.HTTP_401_UNAUTHORIZED, detail=str(e)) from e except Exception as e: print(e) raise ValidationException( detail={ "message": "Validation error", "errors": str(e), "documentation_url": "https://api.example.com/docs" } ) from e < /code> Protokoll aus meinem Frontend: < /p> Object [AxiosHeaders] { date: 'Mon, 10 Feb 2025 13:47:16 GMT', server: 'uvicorn', 'content-length': '45', 'content-type': 'application/json', 'set-cookie': [ 'refresh_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjM5LCJleHAiOjE3Mzk4MDAwMzZ9.YnELWecBRiLIDuuZS_RUtfwfdRN--GuL7B5XjvGojKY; HttpOnly; Max-Age=604800; Path=/; SameSite=none', 'access_token="Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjM5LCJleHAiOjE3MzkxOTcwMzd9.3eNjdMx88ax9SpWgcyMkaw3sJCteVfrdUqv7jxTfZVU"; HttpOnly; Max-Age=900; Path=/; SameSite=none' ] }
< /code> Server -Aktion für die Anforderung: < /p> export async function login( formData: FormData ): Promise { const username = String(formData.get("username")); const password = String(formData.get("password"));
Ich sende meine Aktualisierungs- und Zugangs-Token als HTTP-Cookies an die Frontend meiner nächsten J-Anwendung. Wenn ich die Antwortheader im Frontend tröste, bekomme ich die Cookies. Sie werden...
Warum Cookie -Wert nicht erstellt wird, wenn ich die Site (localhost) zum ersten Mal lade? Der Cookie -Wert wird erst festgelegt, nachdem ich die Site schnell genug neu geladen habe...
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
import json
import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
import json
import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
import json
import time