Complete the code to import the NextAuth function from the correct package.
import NextAuth from '[1]';
The NextAuth function is imported from the next-auth package.
Complete the code to add GitHub as an OAuth provider in NextAuth configuration.
providers: [
GitHubProvider({
clientId: process.env.[1]_CLIENT_ID,
clientSecret: process.env.[1]_CLIENT_SECRET
})
],GitHub OAuth credentials are usually stored in environment variables named GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET.
Fix the error in the NextAuth options by completing the secret configuration.
export default NextAuth({
providers: [/* providers here */],
secret: process.env.[1]
});The secret key for NextAuth is conventionally stored in NEXTAUTH_SECRET environment variable.
Fill both blanks to configure Google OAuth provider with environment variables.
providers: [
GoogleProvider({
clientId: process.env.[1],
clientSecret: process.env.[2]
})
],Google OAuth credentials are commonly stored as GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET environment variables.
Fill all three blanks to complete the NextAuth configuration with credentials provider.
CredentialsProvider({
name: 'Credentials',
credentials: {
username: { label: 'Username', type: 'text' },
password: { label: 'Password', type: 'password' }
},
async authorize(credentials) {
const user = await authenticateUser(credentials.[1], credentials.[2]);
if (user) {
return user;
} else {
throw new Error('[3]');
}
}
})The authorize function uses credentials.username and credentials.password to authenticate. The error message should clearly state the login failure reason.