reflex-dev / reflex

🕸️ Web apps in pure Python 🐍
https://reflex.dev
Apache License 2.0
20.14k stars 1.16k forks source link

Cannot find propper way to access query parameters #4258

Closed sabbraxcaddabra closed 1 week ago

sabbraxcaddabra commented 1 week ago

Cannot find propper way to access query parameters to get access token from redirecting on my reflex frontend app

My State class is:

class State(rx.State):
    """The app state."""

    @rx.var
    def get_access_token(self):
        query_params = self.router.page.params
        print(query_params)
        access_token = query_params.get('access_token')
        print(access_token)
        return access_token

And my auth rout:

@rx.page(route='/app/auth/[[...]]', )
def auth():
    return rx.box(
        rx.text(State.get_access_token)
    )

First of all I try the following url http://localhost:8050/app/auth/#access_token=my_token/ and this give me nothing (just blank white screen). Then I try url http://localhost:8050/app/auth/access_token=my_token/ without # symbol and get in my console output from get_access_token method.

{'': ['access_token=my_token']}
None

I want to use the reflex routes with query parameters like http://localhost:8050/app/auth/#access_token=my_token/ Is there any chance do it?

linear[bot] commented 1 week ago

ENG-4018 Cannot find propper way to access query parameters

Lendemor commented 1 week ago

Tested your snippet locally, they are working properly when using this url : http://localhost:3002/app/auth/?access_token="foobarbaz"