Back

OAuth2 - what to do after session is created?

  • 0
  • Accounts
  • Web
  • Cloud
pietrodc0
2 Jun, 2023, 16:48

Using the web SDK and AW Cloud, I call createOAuth2Session that performs the redirect to the provider's login page and then the user is redirected to the success url. The url doesn't contain query parameters and I don't understand how to know which user has been created or logged in. What I'm missing?

TL;DR
After creating a session using OAuth2, you need to specify two URLs - one for success and one for failure. After the user is redirected to the success URL, you should show the appropriate data to the user. Additionally, you need to call `account.get()` to start the session. If you're not seeing data in local storage, session storage, or cookies, you may be missing this step. More information can be found in the provided Discord link.
Binyamin
2 Jun, 2023, 16:50

When calling the createOAuth2Session you'll provide two URLs

  1. On success
  2. On failure.

After each you should show the user the appropriate data.

P.s. On success you then need to run account.get() to let the session start. See more about that here https://discord.com/channels/564160730845151244/1111116935938187294/1111119219094994966

Binyamin
2 Jun, 2023, 16:53

btw, Vanilla OS looks nice

pietrodc0
2 Jun, 2023, 16:54

What is the SDK using to make account.get() to work? I don't see data in the local storage nor in session storage nor in cookies

pietrodc0
2 Jun, 2023, 16:54

thanks for the hint anyway! and thanks for Vanilla 😛

Binyamin
2 Jun, 2023, 16:54

That's because the cookie are saved on Appwrite domain Like here

pietrodc0
2 Jun, 2023, 16:55

oh, I understand!

pietrodc0
2 Jun, 2023, 16:55

now all makes sense

Binyamin
2 Jun, 2023, 16:56

👍

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more