ngasull
04/26/2023, 1:20 PMflowType: "pkce"
but auth flow doesn't seem to be working in local auth: signInWithOtp
sends the email but the auth API redirects me to #error=invalid_request&error_code=400&error_description=Verify+requires+a+token
, which is probably an error from the implicit
flow.
Did I miss something, like upgrading something manually? Is the CLI actually ready for PKCE? Thanks a lot and keep up with the good work! 🙂👍
CLI: 1.50.14
supabase-js: 2.21.0
NB: I'm calling signInWithOtp
from the server-side client.supafloh
04/26/2023, 2:48 PMand_g
04/26/2023, 3:00 PMaccess_token
, but when I use it in Notion client I am getting an error: "API token is invalid."
Here https://github.com/orgs/supabase/discussions/5787#discussioncomment-5470051 is how I implemented authentication flow:
When `onAuthStateChange`'s callback occurs on SIGNED_IN
event, I got an access_token
and set up notionClient
.
The problem is that if I use the access_token
, I get the error: "API token is invalid."
I got this error if I call GET_NOTION_PAGE
in my code. I also tried to use the access_token
directly through rest api call and i am getting the same error:
https://cdn.discordapp.com/attachments/1100798506333118666/1100798506970648646/Screenshot_2023-04-26_at_09.47.33.png▾
https://cdn.discordapp.com/attachments/1100798506333118666/1100798507545272370/Screenshot_2023-04-26_at_14.34.55.png▾
Nico PM
04/26/2023, 4:55 PMAmbidextrousMoose
04/26/2023, 4:56 PMError: cannot parse `db.${db-code}.supabase.co`: failed to parse as DSN (invalid dsn)
This happens with this command set on all three commands
supabase db dump --db-url "$OLD_DB_URL" -f roles.sql --role-only
supabase db dump --db-url "$OLD_DB_URL" -f schema.sql
supabase db dump --db-url "$OLD_DB_URL" -f data.sql --data-only
I stored the url as a variable with
OLD_DB_URL="db.${db-code}.supabase.co"
I've tried variations with https://
as a part of the url to no avail.
Am I supposed to be formatting this url a certain way? The docs say DB Url, but DSN's are typically a URI created with a postgresql
prefix on the URI with some other jutsu inside of it.TuxedoMad
04/26/2023, 5:07 PMCREATE POLICY "Enable insert for authenticated users only"
ON "storage"."objects"
AS PERMISSIVE FOR INSERT
TO authenticated
WITH CHECK (true)
CREATE POLICY "Enable update for authenticated users only"
ON "storage"."objects"
AS PERMISSIVE FOR UPDATE
TO authenticated
USING (true)
WITH CHECK (true)
https://cdn.discordapp.com/attachments/1100830457853128836/1100830458020896908/Screenshot_2023-04-26_110254.png▾
https://cdn.discordapp.com/attachments/1100830457853128836/1100830458415173659/2.png▾
quinn
04/26/2023, 5:21 PMtypescript
const creditCheck = await supbase.functions.invoke(
'handle-event',
{
method: 'POST', body: req.body, headers: {
'user-agent': req.headers['user-agent'] as string,
'test': 'testing',
}
}
);
In this example, user-agent
is coming through as expected, but test
does not. Is there some kind of config I need to set for allowed header values?naonvl
04/26/2023, 5:32 PMquery(chatRoomsRef, where("userIds", "array-contains", currentUserUid));
that's how i did on firebase, i've tried contains
and containedBy
but i need to specify all of the array values, is there a way to achieve this? also i need to listen to the data in realtimemansedan
04/26/2023, 5:37 PMcodedao
04/26/2023, 6:22 PMjustJosuke
04/26/2023, 6:24 PMSpazMonkey
04/26/2023, 7:07 PM.or("title.ilike.value, ...")
so to query the foreign key I tried .or("title.ilike.value,service.name.ilike.value")
but this can't be parsed, I'm guessing because the extra period in "service.name". How can I structure this "or" properly? Do I have to use an RPC for this or is it possible through the JS library? Any and all help is appreciated. Thanks!AwesomeBuff
04/26/2023, 8:07 PMtristansinclair
04/26/2023, 9:25 PMsupabase stop --backup
. My understanding was that supabase stop --backup
would save the data within the backend and re populate tables when booting back up, but this has NOT been my experience. Does anyone understand why?Mohamed Yasser
04/26/2023, 9:31 PMtonyroma
04/26/2023, 9:45 PMCREATE POLICY "policy_name_"
ON public.products
FOR UPDATE
TO 'anon'
USING (
true
);
and my with check expression is
WITH CHECK (true);
I have the anon role and UPDATE operation ticked. But it returns error:
Error adding policy: failed to create pg.policies: syntax error at or near "CREATE"
how should i fix this, thanksfelarchondo
04/26/2023, 10:40 PMprojects
table there is a column named owner_auth_id
of type uuid
that references auth.users.id
.
So the RLS policy should look like USING (auth.uid() = projects.owner_auth_id)
correct?
The other part where the bug may exist is how we set the "auth" part in the client side supabase client. Do we have to do anything special there after the user signs in? I tried adding a supabase.auth.setSession()
call but that didn't seem to fix it.
Thanks in advance!chirptune
04/26/2023, 11:19 PMDECLARE
but that didn't work for meAmateur
04/26/2023, 11:50 PMvinciarts
04/27/2023, 12:38 AMneosavvy
04/27/2023, 1:30 AMesparkman
04/27/2023, 2:22 AMeduardohr
04/27/2023, 2:29 AMsmrz
04/27/2023, 2:33 AMpublic.profiles
, creates a corresponding row in public.calendars
. Locally (supabase db reset
) this works fine: after executing seed.sql
I see the new row in public.calendars
.
When I deploy (supabase db push
), it deploys successfully, but if I try to create a new user (which creates a new row in auth.user
and using the tutorial's user management sql pack, creates a row in public.profiles
), I get back function sync_calendars_with_new_user_profile(public.profiles) does not exist
. When I inspect the GUI, I can see the function is defined (see photos), so it looks like everything should work. I'm really at a loss at how to debug this further. Has anyone run into this?
Here's the code I have defined:
CREATE OR REPLACE FUNCTION sync_calendars_with_new_user_profile(NEW_USER public.profiles) RETURNS void AS $$
DECLARE
title text;
BEGIN
SELECT NEW_USER.full_name || '''' || 's calendar' INTO title;
INSERT INTO public.calendars (id, user_id, is_private, title)
VALUES (gen_random_uuid(), NEW_USER.id, FALSE, title);
RETURN;
END;
$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION sync_calendars_with_new_user_profile_trigger_function() RETURNS trigger AS $$
BEGIN
PERFORM sync_calendars_with_new_user_profile(NEW);
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
CREATE OR REPLACE TRIGGER sync_calendars_with_new_user_profile_trigger AFTER INSERT ON public.profiles
FOR EACH ROW EXECUTE FUNCTION sync_calendars_with_new_user_profile_trigger_function();
And here's my `seed.sql`:
INSERT INTO auth.users (id, email, raw_user_meta_data)
VALUES (gen_random_uuid(), 'foo@gmail.com', '{"full_name": "Foo Bar", "avatar_url": "www.google.com"}');
(Just a reminder: there's another trigger that for each new row in auth.users
creates a new row in public.profiles
, that's an intermediate step).
https://cdn.discordapp.com/attachments/1100972956273889310/1100972956575866900/image.png▾
https://cdn.discordapp.com/attachments/1100972956273889310/1100972956886253629/image.png▾
https://cdn.discordapp.com/attachments/1100972956273889310/1100972957179858975/image.png▾
oski啦
04/27/2023, 5:20 AMCanman
04/27/2023, 5:28 AMcreate function increment_credits (value int, profileid uuid)
returns void as
$$
update profiles
set credits_used = credits_used + value
where id = profileid
$$
language sql volatile;
I tried adding
security definer
set search_path = public
but no luck. Can anyone nudge me in the right direction? Thank you!rchrdnsh
04/27/2023, 6:29 AMjs
import Stripe from 'stripe';
import { error, json } from '@sveltejs/kit';
import { env } from '$env/dynamic/private';
import { supabase } from '$auth/supabase.js';
const stripe = new Stripe(env.SECRET_STRIPE_TEST_KEY)
export async function POST({ request }) {
const body = await request.text()
const signature = request.headers.get('stripe-signature')
try {
event = stripe.webhooks.constructEvent(body, signature, env.SECRET_STRIPE_TEST_WEBHOOK)
} catch (err) {
console.warn('⚠️ Webhook signature verification failed.', err.message)
throw error(400, 'Invalid request')
}
if (event.type === 'checkout.session.completed') {
const checkoutSession = event.data.object;
const user_id = checkoutSession.metadata.user_id;
const customer_id = checkoutSession.customer;
const { data, error } = await supabase
.from('members')
.update({ customer_id: customer_id })
.eq('id', user_id)
.select();
if (error) {
console.error(error);
} else {
console.log('Updated Supabase data:', data);
}
}
return json()
}
...and everything is working from stripe and sveltekit, but the 'members' table is not being updated with the stripe 'customer_id'...
but there are no errors that I can find...
it just...
does't seem to work...
not sure what I'm missing...bradbtw
04/27/2023, 9:05 AMVimes
04/27/2023, 11:29 AMformigueiro
04/27/2023, 12:59 PM