How do I login manually? Using a custom login page
# support-questions
l
How do I login manually? Using a custom login page
r
could you elaborate on your question? It's too vague..
l
Is there any method to login manually with a custom page? such as
supertokens.login(email, password)
client side, i'm not too sure of how the login flow works here in supertokens
r
not yet. However, you can make API calls directly to your backend. The API spec is here: https://app.swaggerhub.com/apis/supertokens/FDI
there is also a blog post that talks about how to do this for social login: https://supertokens.com/blog/adding-social-login-to-your-website-with-supertokens
l
I'm sorry but I dont seem to still understand
r
have you seen the "how supertokens works" page?
and the videos in it?
l
with this custom login page and when the user presses login, what should the button do to sign the user in?
r
it should call the sign in API specified in the swagger spec above.
l
so its
{{supertokensServerUri}}/signin
to login?
r
have you seen the architecture videos in our docs? 🙂
l
I still dont get it sadly
r
hmm.
So have you integrated our backend SDK into your API layer?
l
I guess so yes
I suppose its the one with
Copy code
ts
await superTokensNextWrapper(
    async (next) => {
      await middleware()(req, res, next);
    },
    req,
    res
  );
  if (!res.writableEnded) {
    res.status(404).send("Not found");
  }
r
ok great. Are you calling supertokens.init with a backend config?
l
yup!
r
can i see the config for it?
what is the value of appInfo?
l
serverAddress is
localhost:3000
r
ok. So, from your frontend, you should query
http://localhost:3000/api/auth/signin
POST with the appropriate JSON body (see swagger spec above > emailpassword section)
and make sure you have followed the "reactjs" setup in the quick setup -> frontend section
l
is there a doc for that? swagger is a pain in the eye
r
no other docs.. just swagger
l
alright
thank you^^
It says
not found
Copy code
ts
await NextCors(req, res, {
    methods: ["GET", "HEAD", "PUT", "PATCH", "POST", "DELETE"],
    origin: serverAddress,
    credentials: true,
    allowedHeaders: ["content-type", ...supertokens.getAllCORSHeaders()],
  });

  await superTokensNextWrapper(
    async (next) => {
      await middleware()(req, res, next);
    },
    req,
    res
  );
  if (!res.writableEnded) {
    res.status(404).send("Not found");
  }
r
Can you enable debug logging and then query it again? What are the logs?
l
How do I enable debug logging?
r
there is a troubleshooting section in the docs
l
Copy code
ts
  com.supertokens {t: "2022-04-28T10:21:46.241Z", message: "session init: sessionExpiredStatusCode: 401", file: "/Users/farrelldjohan/Documents/SpaceXLiquid/Playground/NextJS/pishelo/node_modules/supertokens-node/lib/build/recipe/session/recipe.js:171:18" sdkVer: "9.2.0"} +0ms

  com.supertokens {t: "2022-04-28T10:21:46.255Z", message: "middleware: Started", file: "/Users/farrelldjohan/Documents/SpaceXLiquid/Playground/NextJS/pishelo/node_modules/supertokens-node/lib/build/supertokens.js:158:26" sdkVer: "9.2.0"} +0ms

  com.supertokens {t: "2022-04-28T10:21:46.256Z", message: "middleware: requestRID is: undefined", file: "/Users/farrelldjohan/Documents/SpaceXLiquid/Playground/NextJS/pishelo/node_modules/supertokens-node/lib/build/supertokens.js:172:26" sdkVer: "9.2.0"} +0ms

  com.supertokens {t: "2022-04-28T10:21:46.256Z", message: "middleware: Checking recipe ID for match: emailpassword", file: "/Users/farrelldjohan/Documents/SpaceXLiquid/Playground/NextJS/pishelo/node_modules/supertokens-node/lib/build/supertokens.js:220:34" sdkVer: "9.2.0"} +0ms

  com.supertokens {t: "2022-04-28T10:21:46.257Z", message: "middleware: Checking recipe ID for match: session", file: "/Users/farrelldjohan/Documents/SpaceXLiquid/Playground/NextJS/pishelo/node_modules/supertokens-node/lib/build/supertokens.js:220:34" sdkVer: "9.2.0"} +0ms

  com.supertokens {t: "2022-04-28T10:21:46.257Z", message: "middleware: Not handling because no recipe matched", file: "/Users/farrelldjohan/Documents/SpaceXLiquid/Playground/NextJS/pishelo/node_modules/supertokens-node/lib/build/supertokens.js:243:30" sdkVer: "9.2.0"} +0ms
r
the swagger spec says its a POST API
but you are sending a GET request
thats why not found
l
Ahhh alright my bad
sorry
11 Views