https://supertokens.com/ logo
d

DeadWaist

03/23/2022, 6:33 PM
can anyone help me setting up supertoken with django
r

rp

03/23/2022, 6:36 PM
Hey @User let’s talk here
d

DeadWaist

03/23/2022, 6:37 PM
sure
I added the middleware
but not able to access the url
404
r

rp

03/23/2022, 6:37 PM
Can I see the code? And how you are querying the server?
d

DeadWaist

03/23/2022, 6:38 PM
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

03/23/2022, 6:40 PM
And also can I see the supertokens init function call?
d

DeadWaist

03/23/2022, 6:41 PM
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

03/23/2022, 6:42 PM
Looks about right.
Can I see how you are querying the server?
d

DeadWaist

03/23/2022, 6:43 PM
via postman
Copy code
{
  "formFields": [
    {
      "id": "email",
      "value": "johndoe@gmail.com"
    },
    {
      "id": "password",
      "value": "testPass123"
    }
  ]
}
r

rp

03/23/2022, 6:43 PM
POST request?
d

DeadWaist

03/23/2022, 6:44 PM
yes
Copy code
{
  "user": {
    "id": "14a5926e-41bc-4735-989e-f539209c740e",
    "email": "johndoe@gmail.com",
    "timeJoined": 1648060951760
  },
  "status": "OK"
}
r

rp

03/23/2022, 6:44 PM
So it works?
d

DeadWaist

03/23/2022, 6:44 PM
but no new user in authentication.User model
i mean auth/user
r

rp

03/23/2022, 6:45 PM
I’m not sure I follow
d

DeadWaist

03/23/2022, 6:45 PM
DJango admin
r

rp

03/23/2022, 6:45 PM
Hmmm I see.
The user will be created in supertokes. I’m not sure if that syncs with the django admin portal
d

DeadWaist

03/23/2022, 6:46 PM
I don't know, what am I doing wrong
r

rp

03/23/2022, 6:46 PM
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

03/23/2022, 6:47 PM
okay
r

rp

03/23/2022, 6:48 PM
Is that a big issue?
d

DeadWaist

03/23/2022, 6:48 PM
how can i check
if this works
any suggestions
r

rp

03/23/2022, 6:50 PM
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

03/23/2022, 6:53 PM
so, i can also enable jwt to use this with rest framework
r

rp

03/23/2022, 6:54 PM
Yes. You can.
d

DeadWaist

03/23/2022, 6:54 PM
thanks for the help. I misunderstood the steps
r

rp

03/23/2022, 6:55 PM
Happy to help! Does it work now!
? *
d

DeadWaist

03/23/2022, 6:55 PM
yes
Now I understand the working process
will try this with Django Rest Framework to implement this in my existing projects