can anyone help me setting up supertoken with djan...
# community
d
can anyone help me setting up supertoken with django
r
Hey @User let’s talk here
d
sure
I added the middleware
but not able to access the url
404
r
Can I see the code? And how you are querying the server?
d
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
And also can I see the supertokens init function call?
d
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
Looks about right.
Can I see how you are querying the server?
d
via postman
Copy code
{
  "formFields": [
    {
      "id": "email",
      "value": "johndoe@gmail.com"
    },
    {
      "id": "password",
      "value": "testPass123"
    }
  ]
}
r
POST request?
d
yes
Copy code
{
  "user": {
    "id": "14a5926e-41bc-4735-989e-f539209c740e",
    "email": "johndoe@gmail.com",
    "timeJoined": 1648060951760
  },
  "status": "OK"
}
r
So it works?
d
but no new user in authentication.User model
i mean auth/user
r
I’m not sure I follow
d
DJango admin
r
Hmmm I see.
The user will be created in supertokes. I’m not sure if that syncs with the django admin portal
d
I don't know, what am I doing wrong
r
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
okay
r
Is that a big issue?
d
how can i check
if this works
any suggestions
r
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
so, i can also enable jwt to use this with rest framework
r
Yes. You can.
d
thanks for the help. I misunderstood the steps
r
Happy to help! Does it work now!
? *
d
yes
Now I understand the working process
will try this with Django Rest Framework to implement this in my existing projects