Back

Python SDK: Login issue

  • 0
  • Tools
  • Accounts
  • General
  • Users
  • REST API
shubhamm6996
22 Nov, 2023, 21:33

I'm searching and trying to login using python SDK for appwrite using Account and Users.. but can only see how to "create" a new user using Users().create(user-object-data), but there isnt anything for creating Email session connected to login system.. its only available for node js and other things not available in python SDK.. please help

TL;DR
The user is having issues with creating a login system using Appwrite SDK in Python. They are trying to create a session on the client side and trigger background tasks on the server side using Flask and Celery. However, they are unsure about how to handle user sessions and verify if a user is logged in. They ask if they should use both the server SDK and client SDK together. The suggested solution is to create the session on the client side and pass it to the server side for verification. The server SDK can then manipulate the session as needed. It is mentioned that the Python SDK does not have a specific method for creating sessions, but
shubhamm6996
22 Nov, 2023, 21:50

There is no "create-session" method available in the python-sdk...

Drake
22 Nov, 2023, 22:13

yes, we have Client and Server SDKs. Creating a session is only available in a Client SDK. See https://appwrite.io/docs/sdks

Can you provide some more context on what you're building?

shubhamm6996
22 Nov, 2023, 22:28

Yes sir, i checked the docs, but there's everything related to session present in sdks as well, except for creating session in python sdk, i think that should also have been there, since you're providing listing of sessions, deleting of sessions getting sessions based on session ID, etc.

so my customer wants a login system built with dashboard and users should be able to paste video links, which will be converted to audio and added to theri respective google drive links

my approach: i'm using flask as backend, and next-js for frontend video-audio conversion : will come from frontend to flask and then to background process audio-upload: will trigger from frontend to flask and then to background process thought: since the video to audio conversion and audio upload to google drive is long process (this has to be background process, hence i'll be using celery to achieve this part)

but this celery can only be triggered from frontend > flask > celery

eventually i want to deploy this to AWS, as my customer has some credits available there, (so i'm using cloud functionality and not the docker for local system) please let me know your thoughts on this!

ideclon
23 Nov, 2023, 00:17

It doesn't really make sense to create a session fron the server SDK, as users don't interact directly from the server. It does make sense to manipulate created sessions from the server side though.

shubhamm6996
23 Nov, 2023, 00:23

But how can I manipulate created sessions from server side, if I'm not able to create it at first place from server, server sdks can update, verify, get ,etc., only thing which is not available to create session...

What's your solution to this? Should I use both server sdk and client sdk together? Client sdk may create-email-session
Server sdk to coordinate between database and user session

ideclon
23 Nov, 2023, 00:31

Why do you need to create sessions from the server side? What do you want to do with those sessions?

shubhamm6996
23 Nov, 2023, 00:31

If I use next js with appwrite ( client sdk) for registering login sessions, etc. , I won't be able to use python functions which are required to check if user is logged in and has set some heavy task to run,

So to this I have to add flask + celery to handle the huge background task,

Now if I have to check user session, I may need to able to create it from server sdk is what I'm asking

ideclon
23 Nov, 2023, 00:35

Sorry, still not getting it. If you created a session on the client side and another on the server side, how would that help you to know whether or not the user is signed in on the client side?

shubhamm6996
23 Nov, 2023, 00:45

Session will be created only on 1 side, and handled by server, client will only display whatever is necessary based on session

My question was, suppose I'm creating a session using client sdk, now I have several tasks that takes time to run and only be able to run when user triggers the task ( which is in python, so to handle this I have used flask, and for background process using celery )

I want that only user-in-session should be able to run a specific task

And to check if user-in-session on server(flask) I had to create the session here instead on client (next js)

To solve this, I could create session on client, and just trigger celery functions using flask without checking for session, since user will already be in session to run the task?

As soon as task finishes it should also make several entries in database related to user, and task can be finished on server so I definitely need server sdk for this

ideclon
23 Nov, 2023, 00:52

Just to confirm - where are you running these - on your own server or in an Appwrite Function.

If I'm understanding you correctly, the recommended method is to create a JWT on the client side, and pass it over to the server side. You can use that to verify the user.

shubhamm6996
23 Nov, 2023, 00:57

If I create jwt on client and send it to server, I need to store it on server or maybe set cookies

Using: Appwrite cloud.io (trying to use) Backend flask server Frontend NextJs

This is my first project with appwrite

ideclon
23 Nov, 2023, 00:58

No, you just need to use it once to get the user data. JWTs expire after 15 minutes, anyway.

ideclon
23 Nov, 2023, 01:00

If these "long-running tasks" could be moved to an Appwrite Function, you could dispense with the auth step altogether, because you could trigger the Function from the frontend via the SDK, which handles the Auth for you

shubhamm6996
23 Nov, 2023, 01:04

Yes, I think that will be more easy solution to all this, I have to read about that... I usually create this auth from scratch everytime and used firebase couple of times, but appwrite seems more flexible to use, hopefully I could connect these functions with client using appwrite and deploy

Thank you so much for your help I'll be back if I have doubts about other things.. <:appwrite:1156975611466764298>

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