https://supertokens.com/ logo
Docs
Join the conversationJoin Discord
Channels
community
contributing
general
github-activity
info
introductions
new-releases
random
security
support-questions
welcome-0xdelusion
welcome-aj-ya
welcome-aleksandrc
welcome-alpinjs
welcome-amberlamps1
welcome-andrew-rodriguez
welcome-ankit-choudhary
welcome-anthony-stod-custodio
welcome-call-in
welcome-chwalbox
welcome-claybiokiller
welcome-co7e
welcome-cosmoecwsa
welcome-devdag
welcome-dinso
welcome-drebotelho
welcome-elio
welcome-ernest
welcome-foxbarrington
welcome-fromscratch
welcome-galto4ir
welcome-goetzum
welcome-hay-kot
welcome-himanshu-kukreja
welcome-hossambarakat
welcome-ichikawakazuto
welcome-jahir9991
welcome-jamesl
welcome-jerry123424
welcome-john-oliver
welcome-jonas-alexanderson
welcome-jxyz
welcome-kelvinwop
welcome-kraz
welcome-lancekey
welcome-leoo
welcome-lukeacollins
welcome-m-j-mon
welcome-malik-khoja
welcome-marco
welcome-mardadi
welcome-meshguy
welcome-metamorph
welcome-mike-tectu
welcome-mirzok
welcome-mozomig
welcome-naberyou66_
welcome-nacer
welcome-namratha
welcome-naveenkumar
welcome-nightlight
welcome-nischith
welcome-notankit
welcome-olawumi
welcome-pavan-kumar-reddy-n
welcome-pineappaul
welcome-poothebear
welcome-rick
welcome-samuel-qosenergy
welcome-samuelstroschein
welcome-shubhamgoel23
welcome-shubhamkaushal
welcome-sidebar
welcome-surajsli
welcome-suyash_
welcome-syntaxerror
welcome-tauno
welcome-tauno
welcome-tawnoz
welcome-teclali
welcome-tls
welcome-turbosepp
welcome-vikram_shadow
welcome-yann
Powered by Linen
support-questions
  • l

    lavenderlav

    04/30/2022, 3:41 PM
    I did
    ts
    import * as stSessions from "supertokens-auth-react/recipe/session"; 
    stSessions.init();
    but it seems to still not work
  • r

    rp

    04/30/2022, 3:42 PM
    Hmm. You need to do supertokens.init and inside that, there is a recipeList argument, and in there you need to do session.init
  • l

    lavenderlav

    04/30/2022, 3:48 PM
    Seems like the issue was fixed by dynamically importing it
  • l

    lavenderlav

    04/30/2022, 3:48 PM
    but still says no sessions found, any wonders why?
  • r

    rp

    04/30/2022, 3:49 PM
    You need to put it in supertokens.init
  • l

    lavenderlav

    04/30/2022, 3:49 PM
    ts
    const SessionAuthNoSSR = dynamic(
        new Promise<any>((res) =>
            res(SessionRecipe.SessionAuth)
        ),
        { ssr: false }
    )
    
    return (
       <SessionAuthNoSSR>
          props here
       </SessionAuthNoSSR>
    )
  • l

    lavenderlav

    04/30/2022, 4:01 PM
    I still dont get why it doesnt work
    r
    63 replies Β· 2 participants
  • c

    CuriousCI

    04/30/2022, 5:10 PM
    In Python, is @verify_session() the only way to verify a session? I'm having some trouble in a function:
    class DonationViewSet(viewsets.ModelViewSet):
        queryset = Donation.objects.all()
        serializer_class = DonationSerializer
    
        @verify_session()
        async def get_queryset(self):
            session: SessionContainer = self.request.supertokens
            user_id = session.get_user_id()
            return Donation.objects.filter(user_id_id=user_id)
    'coroutine' object is not iterable edit 1 I fixed this problem, I had to import verify_session from syncio, not asyncio, and remove the async keyword, but I got into another problem: verify_session is looking for the parameter request, but it is inside 'self' edit 2 I copied the implementetion of verify_session for Django, and it works edit 3 The best solution I found was creating another function inside the function to verify the session and return it (with @verify_session()), much cleaner
    class DonationViewSet(viewsets.ModelViewSet):
        queryset = Donation.objects.all()
        serializer_class = DonationSerializer
    
        def get_queryset(self):
            @verify_session()
            def verify(request):
                return request.supertokens
    
            session = verify(self.request)
            user_id = session.get_user_id()
            return Donation.objects.all(user_id_id=user_id)
    I wrote this process, for everyone using Django REST framework like in my case.
  • g

    gitcommitshow

    04/30/2022, 6:42 PM
    I am working on handling expired sessions in express. I used
    verifySession
    middleware. When the token is expired, it sends 401 response with json response
    {"message":"try refresh token"}
    . Instead of this, I want to send an html page. So I decided to use
    onUnAuthorised
    event in SuperTokens node sdk.
    Session.init({      
      errorHandlers: {        
        onUnauthorised: async (message, request, response) => {                             console.log(message);        
           // But this didn't print anything
        },
    ....
    To test the fn, I logged but I didn't see anything printed in console. 1. Am I using 'onUnAuthorised' event correctly? 2. Is 'onUnAuthorised` event the correct place to override the behaviour on token expiry? Do we have any example or reference for this event?
  • r

    rp

    05/01/2022, 5:35 AM
    On unauthorised is not called when it’s try refresh token
  • g

    gitcommitshow

    05/01/2022, 6:46 AM
    Is there any other event that's called then? How can I achieve above requirement?
  • r

    rp

    05/01/2022, 8:09 AM
    See NextJS section -> session verification -> ssr method. Even if you are not using NextJS, you can do something similar
    g
    16 replies Β· 2 participants
  • r

    ravaelamanov

    05/01/2022, 10:49 AM
    Hello, there! I'm currently trying to implement third party recipe in my project (vanilla js + nestjs). I added the backend support which seems to be working fine. Now I'm trying to implement a custom login ui according to this guide: https://supertokens.com/blog/adding-social-login-to-your-website-with-supertokens. I managed to successfully redirect the user to the third party auth page which is step 1 of the guide, however I'm not really understanding where I'm supposed to place the code of step 2. I would be very grateful if somebody could clarify it for me.
    r
    6 replies Β· 2 participants
  • c

    CuriousCI

    05/01/2022, 11:32 AM
    I can't find the API request to ask the backend to send a verification email...
    r
    4 replies Β· 2 participants
  • r

    rp

    05/01/2022, 12:26 PM
    Custom UI social login
  • r

    rp

    05/01/2022, 12:27 PM
    Email verification
  • g

    gitcommitshow

    05/01/2022, 12:46 PM
    See NextJS section session verification
  • g

    gitcommitshow

    05/02/2022, 1:25 AM
    What does
    Session.refreshToken
    does? How to find the references of this function. The SDK reference doesn't say much about it https://supertokens.com/docs/nodejs/modules/recipe_session.html#refreshSession-1
    n
    4 replies Β· 2 participants
  • s

    solminded

    05/02/2022, 1:33 AM
    Hi again. I have implemented an auth flow with expressjs server + react native on localhost, ngrok and Hasura before. It was working great. Today I have switched to a vercel app following the example here https://github.com/supertokens/supertokens-auth-react/blob/master/examples/with-emailpassword-vercel/api/index.js. Again everything works fine except SuperTokens.getAccessTokenPayloadSecurely()).jwt. When I try to get the JWT it returns
    Could not refresh session
    error.
    r
    23 replies Β· 2 participants
  • g

    gitcommitshow

    05/02/2022, 2:24 AM
    recipesession | supertokens-node
  • x

    XxX_MLG Noob_XxX

    05/02/2022, 3:45 PM
    Does
    SuperTokens
    support regular form HTTP posts? (As opposed to using json-ified data)
    r
    10 replies Β· 2 participants
  • x

    XxX_MLG Noob_XxX

    05/02/2022, 4:41 PM
    Does optional
    verifySession
    still work correctly? πŸ€” Even when I set
    sessionRequired: false
    , I'm getting 401s.
    r
    9 replies Β· 2 participants
  • u

    [Manicraft1001]

    05/03/2022, 9:38 AM
    Hi, I'm having issues to add a username. The entire override does not get called whenever I register a new account. https://supertokens.com/docs/thirdpartyemailpassword/common-customizations/signup-form/adding-fields
    typescript
    
    const initSuperTokens = () => {
      supertokens.init({
        framework: "express",
        supertokens: {
          connectionURI: "REDACTED",
          apiKey: "REDACTED",
        },
        appInfo: {
          appName: "REDACTED",
          apiDomain: "http://localhost:3000",
          websiteDomain: "http://localhost:3000",
          apiBasePath: "/api/authentication",
          websiteBasePath: "/authentication",
        },
        recipeList: [
          ThirdPartyEmailPassword.init({
            override: {
              apis: (originalImplementation) => {
                return {
                  ...originalImplementation,
                  emailPasswordSignUpPOST: async function (input) {
                    if (
                      originalImplementation.emailPasswordSignUpPOST === undefined
                    ) {
                      throw Error("Should never come here");
                    }
    
                    // First we call the original implementation
                    let response =
                      await originalImplementation.emailPasswordSignUpPOST(input);
    
                    console.log("response");
                    console.log(response);
    
                    // If sign up was successful
                    if (response.status === "OK") {
                      // We can get the form fields from the input like this
                      let formFields = input.formFields;
                      let user = response.user;
    
                      console.log(formFields);
                      console.log(user);
                      // TODO: register user in the database
    
                      // some post sign up logic
                    }
    
                    return response;
                  },
                };
              },
            },
          }),
          Session.init(), // initializes session features
        ],
      });
    };
    
    export default initSuperTokens;
    p
    25 replies Β· 2 participants
  • n

    NicolaiVdS

    05/03/2022, 10:07 AM
    i am setting up SuperTokens with docker-compose but when SuperTokens starts it says that is using memory storage this is my docker-compose file:
    psql:
        image: postgres
        container_name: postgress
        restart: unless-stopped
        ports:
          - "5432:5432"
        volumes:
          - ./docker/psql/data:/var/lib/postgresql/data
        environment:
          POSTGRES_USER: ${POSTGRES_USER}
          POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
          POSTGRES_DB: ${POSTGRES_DB}
    
      supertokens:
        image: registry.supertokens.io/supertokens/supertokens-postgresql
        container_name: supertokens
        restart: unless-stopped
        ports:
          - 3567:3567
        environment:
          POSTGRES_USER: ${POSTGRES_USER}
          POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
          POSTGRESQL_DATABASE_NAME: ${POSTGRES_DB}
        depends_on:
          - psql
    and yes i started the db first
    p
    3 replies Β· 2 participants
  • w

    wdjzr

    05/03/2022, 1:56 PM
    Hi guys, trying to test supertokens but I can not start the docker instance if I use
    192.168.1.16
    as the psql host
  • w

    wdjzr

    05/03/2022, 1:56 PM
    If I use localhost for example, it starts and I can see the instance with 'docker ps', but of course then it doesnt connect
  • w

    wdjzr

    05/03/2022, 1:56 PM
    I also tested connecting to the database with
    192.168.1.16
    outside the docker and it works without any issues
  • w

    wdjzr

    05/03/2022, 1:57 PM
    How can I troubleshoot this? Docker instance instantly dissapppears after the command so I couldnt check the logs
    p
    r
    27 replies Β· 3 participants
  • c

    codingtomato

    05/03/2022, 2:28 PM
    Hey πŸ‘‹ First of all I have to say that SuperTokens is such a great project! I'm using it for a sample project. Now I'm wondering if anybody knows if there is a way to secure a socket.io connection with SuperTokens? Thanks for your help!
    r
    5 replies Β· 2 participants
  • r

    rp

    05/03/2022, 5:31 PM
    message has been deleted
    3 replies Β· 1 participant
Powered by Linen
Title
r

rp

05/03/2022, 5:31 PM
message has been deleted
Hey @Sup
We have a blog post explaining exactly how to go about this
https://supertokens.com/blog/adding-social-login-to-your-website-with-supertokens
View count: 2