I’m having trouble with my FastAPI app using Google OAuth. The authentication token isn’t showing up in the browser cookies after the callback. Here’s what I’ve tried:
I’m setting the cookie in the response and redirecting to the frontend. But the cookie isn’t there when I check. Am I missing something? Is there a better way to get the token to the frontend securely? Any help would be great!
I encountered a similar issue in my FastAPI project. The problem might be related to the domain setting. Try changing ‘domain='localhost'’ to use ‘samesite='lax'’. This worked for me:
Additionally, ensure your frontend is configured to accept and send cookies with credentials. In your API calls, include the option ‘credentials: include’. For example, if you’re using Axios, set:
axios.defaults.withCredentials = true;
These adjustments should help your frontend receive the authentication token securely.
yo, had similar probs. try setting secure=True in ur cookie options. also, make sure ur frontend and backend are on same domain (both localhost). if that don’t work, maybe look into using JWT tokens instead? they’re pretty cool for auth stuff. good luck!
hmmm, interesting issue! Have u tried checking the network tab in devtools to see if the cookie is actually being set? sometimes it’s there but not visible in the application tab. Also, what about using localStorage instead of cookies? might be easier to manage. curious to hear what others think!