Thread
#community
    d

    DeadWaist

    6 months ago
    can anyone help me setting up supertoken with django
    r

    rp

    6 months ago
    Hey @User let’s talk here
    d

    DeadWaist

    6 months ago
    sure
    I added the middleware
    but not able to access the url
    404
    r

    rp

    6 months ago
    Can I see the code? And how you are querying the server?
    d

    DeadWaist

    6 months ago
    INSTALLED_APPS = [ "django.contrib.admin", "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", "corsheaders", "supertokens_python", ] MIDDLEWARE = [ "django.middleware.security.SecurityMiddleware", "django.contrib.sessions.middleware.SessionMiddleware", "django.middleware.common.CommonMiddleware", "corsheaders.middleware.CorsMiddleware", "django.middleware.csrf.CsrfViewMiddleware", "django.contrib.auth.middleware.AuthenticationMiddleware", "django.contrib.messages.middleware.MessageMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware", "supertokens_python.framework.django.django_middleware.middleware", ]
    r

    rp

    6 months ago
    And also can I see the supertokens init function call?
    d

    DeadWaist

    6 months ago
    from supertokens_python.recipe.thirdpartyemailpassword import Github from supertokens_python import init, InputAppInfo, SupertokensConfig from supertokens_python.recipe import thirdpartyemailpassword, session init( app_info=InputAppInfo( app_name="FoodOrdering", api_domain="http://localhost:8000", website_domain="http://localhost:3000", api_base_path="/auth", website_base_path="/auth", ), supertokens_config=SupertokensConfig( # These are the connection details of the app you created on supertokens.com connection_uri="someToken, api_key="someToken", ), framework="django", recipe_list=[ session.init(), # initializes session features thirdpartyemailpassword.init( # TODO: See next step providers=[ Github( client_id="someToken", client_secret="someToken", ), ] ), ], mode="wsgi", # use wsgi if you are running django server in sync mode )
    i replaced the token
    r

    rp

    6 months ago
    Looks about right.
    Can I see how you are querying the server?
    d

    DeadWaist

    6 months ago
    via postman
    { "formFields": [ { "id": "email", "value": "johndoe@gmail.com" }, { "id": "password", "value": "testPass123" } ] }
    r

    rp

    6 months ago
    POST request?
    d

    DeadWaist

    6 months ago
    yes
    { "user": { "id": "14a5926e-41bc-4735-989e-f539209c740e", "email": "johndoe@gmail.com", "timeJoined": 1648060951760 }, "status": "OK" }
    r

    rp

    6 months ago
    So it works?
    d

    DeadWaist

    6 months ago
    but no new user in authentication.User model
    i mean auth/user
    r

    rp

    6 months ago
    I’m not sure I follow
    d

    DeadWaist

    6 months ago
    DJango admin
    r

    rp

    6 months ago
    Hmmm I see.
    The user will be created in supertokes. I’m not sure if that syncs with the django admin portal
    d

    DeadWaist

    6 months ago
    I don't know, what am I doing wrong
    r

    rp

    6 months ago
    You aren’t doing anything wrong
    I just don’t think that supertokens and django admin portal can work together
    Cause the admin portal probably has its own tables for users. And supertokens has its own different table
    d

    DeadWaist

    6 months ago
    okay
    r

    rp

    6 months ago
    Is that a big issue?
    d

    DeadWaist

    6 months ago
    how can i check
    if this works
    any suggestions
    r

    rp

    6 months ago
    Yes. You can see in the db tables. Or loop through all the users via https://supertokens.com/docs/thirdpartyemailpassword/common-customizations/user-pagination
    Or call the sign in API
    d

    DeadWaist

    6 months ago
    so, i can also enable jwt to use this with rest framework
    r

    rp

    6 months ago
    Yes. You can.
    d

    DeadWaist

    6 months ago
    thanks for the help. I misunderstood the steps
    r

    rp

    6 months ago
    Happy to help! Does it work now!
    ? *
    d

    DeadWaist

    6 months ago
    yes
    Now I understand the working process
    will try this with Django Rest Framework to implement this in my existing projects