In my backend(FastAPI) I'm using supabase to send OTPs, update tables. for this I have this server client.
from supabase import create_client, Client
from app.core.config import settings
class SupabaseClient:
def __init__(self):
supabase_url = settings.supabase_url
supabase_key = settings.supabase_service_role_key
if not supabase_url or not supabase_key:
raise ValueError("Missing Supabase credentials. Set SUPABASE_URL and SUPABASE_SERVICE_ROLE_KEY")
self.client: Client = create_client(supabase_url, supabase_key)
supabase = SupabaseClient().client
but when i use this client to insert into tables it gives me permission denied error. even after disabling row level security.
class ProjectService:
@staticmethod
async def new_project(authContext: Tuple[str, Optional[User]]) -> dict:
token, user = authContext
print(f"user: {user}")
try:
project_data = {}
new_project = {
"user_id": user.id,
"last_modified": datetime.now(timezone.utc).isoformat(),
"project_data": json.dumps(project_data)
}
response = supabase.table("projects").insert(new_project).execute()
print(f"response: {response}")
return SuccessResponseModel(
status="success",
message="OTP sent to your email. Please check your inbox.",
data={}
).model_dump()
except Exception as e:
print('Error in transcription:', e)
error_message = str(e)
error_code = "TRANSCRIBE_ERROR"
raise HTTPException(
status_code=400,
detail={
"status": "error",
"message": error_message,
"error_code": error_code,
}
)
what could be the issue. is there any proper way to define the supabase client and use it.