Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: OAuth - Custom Parameter #297

Open
Droppix opened this issue Nov 30, 2024 · 2 comments
Open

Question: OAuth - Custom Parameter #297

Droppix opened this issue Nov 30, 2024 · 2 comments

Comments

@Droppix
Copy link

Droppix commented Nov 30, 2024

Hi,

Is it possible to pass a custom parameter during OAuth authentication and retrieve it on the server side?

cf:

---> 
/api/auth/google?myparam=1234
-->
export default defineOAuthGoogleEventHandler({
    config: {
        emailRequired: true,
    },
    async onSuccess(event, { user }) {
        const query = getQuery(event)
        // How get ---> query.myparam ???
    }
}

Thks

@druskacik
Copy link

druskacik commented Dec 6, 2024

I would be interested in this as well. Example use case: I have multiple pages that lead to login page and after successful login, I would like to redirect to the source page. This could be encoded in the query parameter.

My current solution is to have multiple defineOAuthGoogleEventHandler definitions, but using a parameter would definitely be more practical.

@atinux
Copy link
Owner

atinux commented Dec 9, 2024

I would suggest to set a cookie on the app-side if the user is logged out when clicking on the login button.

See an example: https://github.com/nuxt/examples/blob/main/examples/auth/local/auth/plugins/0.auth.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants