Back

not able to extract anything from createOAuth2Session zustand store

  • 0
  • Auth
  • Web
  • Cloud
KINGKabir👑
11 Jan, 2025, 20:40

when using createEmailPasswordSession const session = await account.createEmailPasswordSession(email, password) i am able to get the session but when using const session = await account.createOAuth2Session( OAuthProvider.Google, 'http://localhost:3000/', 'http://localhost:3000/logiin/', )

not getting any session

TL;DR
Developers are having trouble extracting information from the createOAuth2Session zustand store. The method does not return session information; instead, it redirects to a success/failure URL. To display user information like avatar and username, use account.getSession('current'). When using createOAuth2Session with Google, the developers are not receiving any session information.
KINGKabir👑
11 Jan, 2025, 20:43
Kenny
11 Jan, 2025, 20:44

I don't believe the oauth method returns any session informaiton, it redirects you to your success/failure url. If you want to check session you can do account.getSession('current');

Kenny
11 Jan, 2025, 20:46

If you look in the docs for this method, it tells you the response.

https://appwrite.io/docs/references/cloud/client-web/account#createOAuth2Session

Here it shows there is no object response but instead a 301 redirect response. Redirecting to your defined success or failure url.

KINGKabir👑
11 Jan, 2025, 20:51

How can i show the user avatar, user name etc information for user profile

do i have to use this const session = await account.getSession("current")

Kenny
11 Jan, 2025, 20:53

Sure, sounds like you probably need to read over the oauth information in the documentation.

https://appwrite.io/docs/products/auth/oauth2#profile

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