I'm facing a problem with my backend app, I want to create 3 endpoint API:
- /login user
- /logout
- /getuser I'm using python FastAPI and supabase, the question is how to create session from my backend app to get connected user information to handle th log_out and the log_in.
log_in function endpoint
@app.post('/login')
async def handel_login(user_mail: str):
if check(user_mail):
print(supabase.auth.sign_in(email=user_mail))
else:
print("incorrect form of email")
log_ou endpoint
@app.get('/logout')
async def handel_logout():
error = supabase.auth.sign_out()
return error
getuser endpoint
@app.get('/getuser')
async def get_user():
user = supabase.auth.user()
return user
in all of this I get None responses!
I was interested in this because I had a next.js app that used supabase cookies for auth. That proved too difficult to pass to the FastApi service. Instead, I extract the access_token via the session, and then just pass it in via authorization header per the fastapi security tutorial.