User profile is not getting returned after succesful login | Auth0 + Next.js SDK

Logs from Auth0 Dashboard shows that logins are successful. However, the user profile is not getting returned

Here is my code.

Setup

import { handleAuth, handleLogin } from "@auth0/nextjs-auth0";

export default handleAuth({
  async login(req, res) {
    try {
      await handleLogin(req, res, {
        authorizationParams: {
          redirect_uri: "http://localhost:3000/dashboard",
          scope: "openid profile email",
          response_type: "code",
        },
      });
    } catch (e) {
      res.status(400).end(e.message);
    }
  },
});

User Dashboard using useUser()

import React from "react";

import Dashboard from "@/Components/Dashboard/Dashboard";
import { useUser } from "@auth0/nextjs-auth0/client";
import Image from "next/image";

export default function DashboardHome() {
  const { user, error, isLoading } = useUser();
  console.log(user);

  if (isLoading) return <div>Loading...</div>;
  if (error) return <div>{error.message}</div>;

  return (
    <>
      <Dashboard />
      {user ? (
        <div>
          <Image src={user.picture} alt={user.name} />
          <h2>{user.name}</h2>
          <p>{user.email}</p>
        </div>
      ) : (
        <p>No user exist yet</p>
      )}
    </>
  );
}

I urgently need help

2 Likes