Code Monkey home page Code Monkey logo

Comments (6)

leynier avatar leynier commented on May 9, 2024 3

When I say, "currently", it is literal 😅. Here you have a preview

def set_auth(self, access_token: str) -> Session:
    """Overrides the JWT on the current client. The JWT will then be sent in
    all subsequent network requests.

    Parameters
    ----------
    access_token : str
        A JWT token

    Returns
    -------
    response : Session
        A logged-in session

    Raises
    ------
    error : ApiError
        If an error occurs
    """
    session = Session(
        access_token=access_token,
        token_type="bearer",
        user=None,
        expires_in=None,
        expires_at=None,
        refresh_token=None,
        provider_token=None,
    )
    if self.current_session:
        session.expires_in = self.current_session.expires_in
        session.expires_at = self.current_session.expires_at
        session.refresh_token = self.current_session.refresh_token
        session.provider_token = self.current_session.provider_token
    self._save_session(session)
    return session

from supabase-py.

leynier avatar leynier commented on May 9, 2024 1

I'm currently working on a PR to add dataclasses to the responses and synchronize the functionalities between gotrue-py and gotrue-js, that functionality that you mention is already in gotrue-js so I will add it to gotrue-py in the PR.

supabase-community/auth-py#23

from supabase-py.

leynier avatar leynier commented on May 9, 2024 1

If I'm not mistaken (because I'm familiar with gotrue, but not much with the other libraries) they don't do the same.

By the way, what you want to make in the 1st option is currently possible. Although I do not know if a new release has been published with that change.

supabase_client = create_client(url, anon_key)
supabase_client.auth.set_auth(user_jwt_key)

https://github.com/supabase-community/gotrue-py/blob/9ba3192dbdccd2f02a4819b52dd6cf51095af7e7/gotrue/client.py#L162

from supabase-py.

0xDebabrata avatar 0xDebabrata commented on May 9, 2024 1

Hey, not sure if I'm doing anything wrong. But the following does not seem to work.

session = supabase.auth.sign_in(email=os.environ.get("EMAIL"), password=os.environ.get("PASS"))

supabase.auth.set_auth(access_token=session.access_token)

data = supabase.table("videos").select("*").execute()
print(len(data.data))

This prints 0 normally but if I create the supabase client with the secret key, it prints the total number of rows. The table has RLS enabled.

from supabase-py.

Antony-Jia avatar Antony-Jia commented on May 9, 2024 1

from supabase import create_client, Client
The Client has no functions called set_auth.
Is that right?

from supabase-py.

karolzlot avatar karolzlot commented on May 9, 2024

Ok thank you!

Is it correct that the effect is the same in two snippets below??

supabase_client = create_client(url, anon_key)
supabase_client.set_auth(user_jwt_key)
supabase_client = create_client(url, user_jwt_key)

from supabase-py.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.