#Next-auth and Mongoose with App Directory
1 messages · Page 1 of 1 (latest)
I'm sorry, but the provided extracts do not contain detailed example code blocks about next-auth, app directory configuration with mongoose, and callbacks (jwt, session). The extracts mainly provide instructions on how to set up GitHub OAuth for authentication using next-auth in a Next.js application.
However, I can guide you on how to set up GitHub OAuth based on the provided extracts:
- Log into your GitHub account and navigate to Settings > Developer Settings > OAuth Apps (https://github.com/settings/apps).
- Click on "Register a new application" or "New GitHub App".
- Fill out the form with your application details. The "Authorization callback URL" should be your Next.js
/api/authroute (e.g.,<http://localhost:3000/api/auth>). - After registering the application, you will receive a Client ID and Client Secret.
- Copy the Client ID and Client Secret into your
.envfile in the root directory of your project. They should be set as theGITHUB_IDandGITHUB_SECRETenvironment variables respectively.
Please note that GitHub only allows one callback URL per app. If you want to deploy your app later with a production URL, you will need to set up a new GitHub OAuth app.