Back

Error while trying to get session data using "account.session() " (Web)

  • 0
  • Accounts
  • Web
D5
3 Jun, 2023, 15:27

Execute accoun.get() on page load to check if the user has logged in and redirect them. To redirect them after login, you will need to trigger redirect after your console.log

TL;DR
The user is experiencing an error when trying to get session data using the "account.session()" method. They are not using server-side rendering and are trying to create a session for an authenticated user. There is a suggestion to migrate the "createEmailSession()" method to the front end. It is mentioned that Appwrite does not have a login route and that there was a recent patch for oauth2 sessions. There is a suggestion to check if the appwrite SDK is being initialized again on the Dashboard page. There is also discussion about the error being related to user authentication and missing scope. It is recommended to try logging in successfully using "account
Harsh.panchal
3 Jun, 2023, 15:27

Yes it is still showing the same , Is there any other changes I should do ?

Harsh.panchal
3 Jun, 2023, 15:30

I don't get it , Can you explain a bit more.

Drake
3 Jun, 2023, 15:32

I'm not quite sure this is related. I thought the problem was only with oauth

D5
3 Jun, 2023, 15:33

He said he wanted to know how to redirect uses when logged in successfully

D5
3 Jun, 2023, 15:34

Basically if accoint.get() doesnt throws an error, that means the user is logged in

Harsh.panchal
3 Jun, 2023, 15:38

What I mean is , I can redirect easily after login and signin of the user , but I need all the information related to the user created session at my home page which can be obtained by calling account.get() function, here this function gives me error that 'user missing scope '.

Now how to resolve this , this is what I want to know .

@Steven @D5 @KehindeJ

D5
3 Jun, 2023, 15:41

Account.get() should give you all user data if it logged in successfully

Harsh.panchal
3 Jun, 2023, 15:43

Ohk , Can I login successfully by doing account.createEmailSession(),

And If yes , then in my case it might login successfully because I receive a token($Id) from it

D5
3 Jun, 2023, 15:45

Yes

Harsh.panchal
3 Jun, 2023, 15:46

Then why , account.get() gives me an error , that user "missing scope "

D5
3 Jun, 2023, 15:47

Maybe user didn't logged successfully or ther's something wrong with your code. From what you sent, user didn't logged in successfully due to an error in appwrite cloud, now fixed

D5
3 Jun, 2023, 15:47

So try again to see if it works now

Drake
3 Jun, 2023, 15:54

Again, I don't think there was any problem with cloud and the create email session API call

D5
3 Jun, 2023, 16:01

The error he sent seemed to be similar and prior to fix Christy applied

KehindeJ
3 Jun, 2023, 16:18

Could it be possible you're getting the error because you're initializing the appwrite SDK again on the Dashboard page?

Drake
3 Jun, 2023, 16:23

The patch we pushed out only pertained to oauth2 sessions

Drake
3 Jun, 2023, 16:26

Appwrite doesn't have a login route. Are you using server side rendering?

Harsh.panchal
3 Jun, 2023, 16:27

Ok, let me check this ,might it solve the issue

Harsh.panchal
3 Jun, 2023, 16:55

I am not rendering through appwrite , I am just trying to get session data for authenticated user by login or sign in , by using account.get() method

Drake
3 Jun, 2023, 17:01

im not sure what you mean. is the createEmailSession() code being executed server side?

Harsh.panchal
3 Jun, 2023, 17:02

Yes it is

Drake
3 Jun, 2023, 17:12

right...so the session is being created server side...where the cookie doesn't get saved. then your front end loads and doesn't have the session at all

Harsh.panchal
3 Jun, 2023, 17:14

So should I need to migrate createEmaillsession () method to front end ?

Drake
3 Jun, 2023, 17:17

Ya, easiest thing to do is to not use server side code/rendering

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