Skip to content

Handling redirect for OAuth callback #434

@MatthewScholefield

Description

@MatthewScholefield

When using OAuth with the cookie backend, the callback like /auth/google/callback responds with a set-cookie header so I would expect that I would set this as the callback URL in my OAuth application so that the cookie would be set on the browser on redirect. However, the content of this page is always null and I couldn't find a way to change this (the redirect_url parameter in get_oath_router doesn't seem to make a difference).

Would it make sense to have a request customizer within get_oauth_router so that we could choose to redirect the user to our application in the callback response?

I read in another issue that fastapi-users is meant to be used for the API only but if that's the case, I'm wondering why there's a cookie auth backend and what the expected method of providing the callback info is. Is the expected method to set the Google callback URL to your frontend application and then have the frontend forward the request to the api backend within javascript?

Edit: Actually, the cookie backend still makes sense because when you use fetch from Javascript, it still sets cookies properly etc. so it's still useful to enable httpOnly auth storage. Anyways, for now I've set the redirect to route to a frontend endpoint that forwards to the backend within javascript, but I do still believe it would be convenient to allow for a simple redirect so that the OAuth provider could route directly to the backend.

- Matthew

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions