Custom Auth

  • When users sign in to your app, send their sign-in credentials (for example, their username and password) to your authentication server. Your server checks the credentials and returns a custom token if they are valid.

  • After you receive the custom token from your authentication server, pass it to signInWithCustomToken to sign in the user:

import { getAuth, signInWithCustomToken } from "firebase/auth";
import { auth } from "../Configs/firebase";

signInWithCustomToken(auth, token)
  .then((userCredential) => {
    // Signed in
    const user = userCredential.user;
    // ...
  })
  .catch((error) => {
    const errorCode = error.code;
    const errorMessage = error.message;
    // ...
  });

Last updated

Was this helpful?