John Davidson

php - Laravel apply form with oauth2 - conceptional question

0 comments
Message:


I try to build an application form, where you have to connect with the discord oauth2 after submitting the application. So I already got the whole oauth set up and I could make a button where you connect with discord and then fill out your form. But I'd like to have the form submit and oauth request with the same button. Now the problem I'm facing, I can't pass adittional data through the oauth request.


My 'applications' table has id, discord_id and form data columns. So my first idea was to just store the form data and make a redirect to the discord oauth page, then return back to the controller and add the id. The problem, I can't pass additional data to the oauth, so I wouldn't be able to assign the users discord id correctly.


Maybe you guys have any ideas or already worked with discord oauth2.


Thanks



My Answer:
One possible solution to this issue is to store the form data temporarily in a session or cache before redirecting the user to the Discord OAuth page. Once the user returns from the OAuth flow, you can retrieve the form data from the session or cache and save it along with the Discord ID in the database.

Here's a high-level overview of how you could implement this:

1. When the user submits the form, store the form data in the session or cache.
2. Redirect the user to the Discord OAuth page.
3. After the user completes the OAuth flow and returns to your application, retrieve the form data from the session or cache.
4. Save the form data along with the Discord ID in the database.

This way, you can associate the form data with the user's Discord ID even though you can't pass additional data through the OAuth request directly.

Another approach could be to modify the OAuth callback URL to include the form data as query parameters. However, this approach may not be recommended as it could expose sensitive information in the URL.

I hope this helps! Let me know if you have any further questions.

Rate this post

5 of 5 based on 9698 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us