https://supabase.com/ logo
Join Discord
Powered by
# help-and-questions
  • How to test custom auth policy?
    j

    JustinT

    11/07/2022, 5:11 AM
    I am writing a custom auth scheme
    Copy code
    SQL
    CREATE POLICY "asf i5g8hi_1" 
    ON storage.objects FOR 
    SELECT TO public USING 
    (((bucket_id = 'results'::text) AND ((storage.foldername(name))[1] = 'results'::text)
    AND (
        ((current_setting('request.headers'::text, true))::json ->> 'blah'::text) = 'bleep'
        )
    ) );
    with some Python
    Copy code
    python
    url: str = os.environ.get("SUPABASE_URL")
    key: str = os.environ.get("SUPABASE_ANON_KEY")
    supabase: Client = create_client(
        url, key, ClientOptions(headers={"blah": "bleep"}))
    storage = supabase.storage()
    buckets = storage.list_buckets()
    results = storage.get_bucket("results")
    but i am having trouble testing/debugging this. Is there anyway to view the auth checking logs? Or to debug this at all?
  • Unable to upload file to a storage bucket.
    a

    Anurag

    11/07/2022, 5:34 AM
    Uploading a file returns an error saying it violates row-level security policy for table "objects".
    n
    • 2
    • 3
  • get public URL of object in storage.objects
    h

    Hege

    11/07/2022, 5:45 AM
    I have a table that references storage.objects on an object_id so it has to be on the uuid, but the method getPublicUrl() expects the path/name of the object but since I know only the uuid I'm unsure on how to get the url (Ofc the bucket is public)
    g
    • 2
    • 27
  • Slow auth actions under load (generateLink, verifyOtp, updateUserById)
    j

    jake.nz

    11/07/2022, 6:23 AM
    Has anyone else had trouble with auth actions (generateLink, verifyOtp, updateUserById) being much slower than expected under load. We're using the 16XL Add-on and DB queries are very fast even with high load but these auth actions take multiple seconds. Does anyone know the implementation details? Maybe there is some throttling to prevent abuse or some operation other than updating the auth.users table that also happens behind the scenes?
    s
    • 2
    • 3
  • I cannot connect to supabase via company internet connection. (I can connect to it with private con)
    f

    Firebat

    11/07/2022, 7:03 AM
    Is there anything I can try on "my" side ?
    s
    • 2
    • 1
  • OAuth adds hash to url
    f

    fattenap

    11/07/2022, 7:34 AM
    Hi, I’m using OAuth and magic Link to auth users and it works great, however once the user is authenticated and it returns after the callback there is a hash added to the URL. Is this expected behaviour or am I doing something wrong? Thanks
    s
    c
    • 3
    • 47
  • SendGrid
    n

    nako

    11/07/2022, 8:14 AM
    Is it possible to send SendGrid dynamic template around auth ?
    o
    • 2
    • 1
  • TypeError client.auth.getSessionFromUrl is not a function
    p

    PlayWolf

    11/07/2022, 10:15 AM
    Hey there. I am having a problem with authentication with supabase. Signing up or logging in works, but when I do so, I am not logged in with the user. When looking for an error I noticed there was an error in the console (See image) As this is probably important for solving the problem: I am using RedwoodJS. Somehow, it appears to me, the AuthProvider does not communicate with the supabase client correctly. Can anyone help me with this?
  • typesafe generic wrapping of the supabase client
    i

    ixxie

    11/07/2022, 11:23 AM
    I'm trying to wrap the generic supabase client class in a typesafe way in my library. It seems the class has three type parameters with constraints, and my goal is to wrap them into a single type which I can pass around my library. I'm having trouble fulfilling the constraints even though I literally copy them into my wrapper type alias from the library. Here is a minimal example of what I am trying to do (compiler error is highlighted in line 43 near the end): https://codesandbox.io/s/wrapped-generic-w-contraints-bzky59?file=/src/index.ts Note - I had to copy some types from the supabase codebase since they are not exported; am I missing something or should the supabase team consider exporting these for the sake of library developers?
    g
    d
    • 3
    • 12
  • Cannot `supabase db push` after adding local migrations
    c

    chrismasters

    11/07/2022, 11:35 AM
    I have created a local migration which adds a table and modifies an existing one. After running
    supabase db reset
    everything works as expected. The problem occurs when trying to push these changes to my production database. I get this error when running
    supabase db push
    Copy code
    Error: ERROR: must be owner of table streams (SQLSTATE 42501); while executing migration 20221106184147
    The debug message doesn't offer much more information
    Copy code
    2022/11/07 12:33:31 PG Recv: {"Type":"ErrorResponse","Severity":"ERROR","SeverityUnlocalized":"ERROR","Code":"42501","Message":"must be owner of table streams","Detail":"","Hint":"","Position":0,"InternalPosition":0,"InternalQuery":"","Where":"","SchemaName":"","TableName":"","ColumnName":"","DataTypeName":"","ConstraintName":"","File":"aclchk.c","Line":3583,"Routine":"aclcheck_error","UnknownFields":null}
    Has anyone experienced this? Would appreciate any advice to resolve. Thanks!
    s
    • 2
    • 7
  • How to select from two tables?
    a

    alx90

    11/07/2022, 12:26 PM
    Hey guys, I sketched a little diagram of my database. Im starting at the website table, here I have to select where website ID === xy. From the website table Im getting the blogid. At the end I have a articles table which contains all the articles which have a blogId... How could I select these data?
    s
    • 2
    • 1
  • Modify JWT and persist to the client
    e

    erock

    11/07/2022, 1:02 PM
    I followed the Auth0 guide (https://supabase.com/docs/guides/integrations/auth0) for a supabase project and saw how we can make our own JWT to give greater control over additional claims added and then accessed by the RLS policies. Can I do this with the native Supabase auth? I am using Next.js and the react/nextjs helper packages for auth. I may have figured out how to accomplish the by using middleware to modify the cookie set by these packages, but is there a better way?
    n
    • 2
    • 1
  • GitHub OAuth always redirects to base URL. redirectTo seems to be ignored in URL
    s

    sudo42

    11/07/2022, 1:58 PM
    GitHub OAuth always redirects to base URL. redirectTo seems to be ignored in URL. If I add it as an option in signinWithOauth(), it doesn't seem to change anything
    j
    g
    • 3
    • 7
  • auth.uid() = user_id not working on server
    d

    dan_v

    11/07/2022, 3:26 PM
    I've been following this RLS video tutorial in the docs, but can't for the life of me get it to work for the currently authenticated user. I have a column in my table called
    user_id
    where I'm saving the uid, and I'm trying to create the following policy.
    Copy code
    CREATE POLICY "Enable select for users based on user_id" ON "public"."user-trips"
    AS PERMISSIVE FOR SELECT
    TO public
    USING (auth.uid() = user_id)
    However when calling
    supabase.from("user-trips").select("*");
    I'm simply getting an empty array. Any ideas what I'm doing wrong?
    n
    g
    • 3
    • 120
  • typescript Object is possibly 'null' ?
    k

    kingpeppe

    11/07/2022, 3:53 PM
    I believe I set it all up correctly but
    tokens.data
    gives me an error > (property) data: (Database[SchemaName] extends GenericSchema ? Database[SchemaName] : any)["Tables"]["tokens"]["Row"][] | null > Object is possibly 'null'.deno-ts(2531) supabase.ts
    Copy code
    ts
    export const getTokens = async () => {
      return await supabase.from('tokens').select('*')
    }
    
    // TYPES
    type TokensResponse = Awaited<ReturnType<typeof getTokens>>
    export type TokensResponseSuccess = TokensResponse['data']
    export type TokensResponseError = TokensResponse['error']
    main.ts
    Copy code
    ts
    const tokens = await getTokens()
    const ids = tokens.data.map(token => token.coingecko_id).filter(id => id != null)
    What am I doing wrong?
    g
    s
    • 3
    • 6
  • correct types for this function?
    k

    kingpeppe

    11/07/2022, 4:23 PM
    How would you correctly type
    getTokenIds()
    ?
    Copy code
    ts
    export const getTokens = async () => {
      return await supabase.from('tokens').select('*')
    }
    export const getTokenIds = tokens => {
      return tokens.data!.map(token => token.coingecko_id).filter(id => id != null)
    }
    getTokens()
    returns
    Copy code
    ts
    {
      error: null,
      data: [{some data}, {some data}]
    }
    would be used in this context
    Copy code
    ts
    const tokens = await getTokens()
    const ids = getTokenIds(tokens)
  • Unable to Get Provider Refresh Token for Google
    s

    sixfour

    11/07/2022, 5:44 PM
    Hi, I am trying to get the Google refresh token without success. I found a related issue about it (https://github.com/supabase/gotrue-js/issues/131#issuecomment-1283457364), saying a fix was merged into GoTrue a few weeks ago. Does anyone know if this fix is live? Any advice/help is appreciated!
    j
    p
    • 3
    • 7
  • V2 Javascript reference docs don't load. Throw 500 error.
    g

    gesusc

    11/07/2022, 6:01 PM
    When I attempt to navigate to any section of the V2 Javascript reference docs the site throws a 500 error. Is this a known issue? See this page for example: https://supabase.com/docs/reference/javascript/auth-signinwithoauth
    s
    s
    • 3
    • 5
  • After applying the patch `revoke superuser access`, local development is broken
    d

    drocha

    11/07/2022, 6:29 PM
    I just applied the patch as suggested in my notifications, then I thought I should "sync" my production with my local development running the command
    supabase db remote commit
    . It generate a new migration, and when I try to run it
    supabase db reset
    I receive this error
    Copy code
    txt
    Error: ERROR: role "postgres_temporary_object_holder" does not exist (SQLSTATE 42704)
    Then I stop supabase, and now I can't even start it, with
    supabase start
    Copy code
    txt
    supabase start
    Applying migration 20221029194050_remote_commit.sql...
    Applying migration 20221107171735_remote_commit.sql...
    Error: ERROR: role "postgres_temporary_object_holder" does not exist (SQLSTATE 42704)
    At statement 0: -- This script was generated by the Schema Diff utility in pgAdmin 4
    -- For the circular dependencies, the order in which Schema Diff writes the objects is not very sophisticated
    -- and may require manual changes to the script to ensure changes are applied in the correct order.
    -- Please report an issue for any failure with the reproduction steps.
    
    ALTER FUNCTION public.handle_new_user()
        OWNER TO postgres_temporary_object_holder;
    Did I did something wrong? I could not understand the steps of applying this migration.
    g
    • 2
    • 4
  • Github email change not detected in app.supabase
    j

    jimmie

    11/07/2022, 7:31 PM
    I added and verified a new email to my github account (and made it the public email currently) after I created a supabase account, but app.supabase doesn't seem to be picking it up. I have an invite for the new email that is not able to be redeemed because my previous email is not the one the invite was sent to.
    • 1
    • 1
  • Understanding Pricing Limits
    a

    Askar

    11/07/2022, 7:47 PM
    What is considered an active user on Supabase? If they are logged in and they are deleted from the
    getUserList
    , do they still count as an active user? What is also considered an
    edge function invocation
    ?
    • 1
    • 1
  • Turn on realtime and RLS via SQL in Local Dev
    z

    ZaDeR47

    11/07/2022, 7:54 PM
    Hey folks - trying to figure out how to turn on realtime and rls for local development, I'd like to have this in my
    seed.sql
    that gets run when I call
    npx supabase start
    - anyone know?
    g
    • 2
    • 3
  • Unable to get realtime data in local dev
    z

    ZaDeR47

    11/07/2022, 8:07 PM
    Seems a bit unclear the format expected for filtering realtime on the docs; I'm trying to filter on my logged in users uuid:
    Copy code
    ts
    // given `const userId: string = '';`
    
    supaClient.channel(`public:user_profiles:user_id=eq.${userId}`)
      .on(
        "postgres_changes",
        {
          event: "*",
          schema: "public",
          table: "user_profiles",
          filter: `user_id=eq.${userId}`, // <== here?
        },
        (payload) => {
          setUserInfo({ ...userInfo, profile: payload.new as UserProfile });
        }
      )
      .subscribe();
    j
    g
    • 3
    • 20
  • Updating many2many relations with RPC call
    c

    config_wizard

    11/07/2022, 8:12 PM
    Hi, from reading here, https://github.com/PostgREST/postgrest/issues/818 I have discovered that I need to create a function that will take the JSON of the object I want to update with all its relations as I can't do it with REST. I'm not quite sure what the function woud look like however to do this. I'm sending JSON in the form
    Copy code
    { //type customer:
        "id": 1,
        "description": "hello world",
        "friends": [
            {
                "id": 3,
                "name": "james bond"
            }
        ]
    }
    I have a table holding all the top level objects, a table holding the friend and a table called
    friends_connections
    which holds the many2many relationships, i.e ID -> ID. Using the javascript supabase library I am think I can do
    rpc("update_contacts", jsonObj)
    but I'm not sure what I would put in the function? I think I could do it by literally updating each part one by one and perhaps pass the
    friends
    as another argument rather than as a child, but I feel there is an atomic way I should be doing this where PSQL is clever enough to rollback the whole thing if something fails. A link of simple example of updating the
    customer
    and the relations to
    friends
    using the
    friends_connections
    table would be really helpful. Thank you!
    g
    • 2
    • 2
  • Error properties Deno
    f

    Fainaru

    11/07/2022, 9:10 PM
    Hello, I have a problem that when uploading my function when using it, it gives me this error
  • Checking for 'null' with the supabase JS api
    g

    gtims123

    11/07/2022, 10:19 PM
    I've been struggling to check for null using the supabase js api. For instance, say I have a json/jsonb column in a table with null for some of the values. How can I check for that? Similarly, what if I have a jsonb or json column with null in some of the JSON payload, such as {"hello": null, "goodbye": {"ok": null}} how can I check for null?
    r
    • 2
    • 2
  • How do I create a composite key?
    l

    lewisd

    11/07/2022, 10:37 PM
    I know how to do this in the UI, but how can I do this in SQL?
    Copy code
    create table "userWantList" (
      userId uuid references "userData" (id) primary key,
      "createdAt" timestamp default now(),
      "collectibleId" character not null primary key,
      "collectibleType" bigint references "collectibleTypes" (id)
    );
    Gives me the error
    multiple primary keys for table "userWantList" are not allowed
    g
    • 2
    • 3
  • Login with wallet, custom JWT
    b

    Berteotti

    11/07/2022, 11:02 PM
    I want to login with wallet (e.g. metamask) and create a JWT that I can give to supabase to authenticate. I followed this tutorial https://supertokens.com/docs/emailpassword/supabase-intergration/policies , but can't login an user yet. Am I missing something?
    g
    • 2
    • 10
  • Supabase with Web3Auth
    j

    jkb5801

    11/07/2022, 11:27 PM
    Hello everyone, I am starting up a new project and I need to utilize the Web3Auth library in order to connect a user to a wallet. Conceptually I am unsure how to use Web3Auth while still having the amazing benefits of the built in Auth packages by Supabase. If there are any Auth experts out there that can help I'd appreciate it. https://web3auth.io/docs/
  • What are the syntax for queries in REST API?
    w

    wolf5

    11/07/2022, 11:53 PM
    For example, I want to fetch a user from a user table by selecting id of 1.
    fetch("https://your-url-supabase.co/rest/v1/user?id=eq.1&select=*")
    What are the syntax for queries of count, range, etc?
    g
    n
    • 3
    • 18
1...626364...230Latest