Files
xrpl-hooks-ide/pages/api/auth/[...nextauth].ts

49 lines
1.4 KiB
TypeScript

import NextAuth from "next-auth"
import GithubProvider from "next-auth/providers/github"
export default NextAuth({
// Configure one or more authentication providers
providers: [
// GithubProvider({
// clientId: process.env.GITHUB_ID,
// clientSecret: process.env.GITHUB_SECRET,
// // @ts-expect-error
// scope: 'user,gist'
// }),
{
id: "github",
name: "GitHub",
type: "oauth",
clientId: process.env.GITHUB_ID,
clientSecret: process.env.GITHUB_SECRET,
authorization: "https://github.com/login/oauth/authorize?scope=read:user+user:email+gist",
token: "https://github.com/login/oauth/access_token",
userinfo: "https://api.github.com/user",
profile(profile) {
console.log(profile)
return {
id: profile.id.toString(),
name: profile.name || profile.login,
email: profile.email,
image: profile.avatar_url,
}
},
}
// ...add more providers here
],
callbacks: {
async jwt({ token, user, account, profile, isNewUser }) {
console.log('jwt', { token, account })
if (account && account.access_token) {
token.accessToken = account.access_token;
}
return token
},
async session({ session, token }) {
console.log('session', { token, session })
session.accessToken = token.accessToken;
return session
}
},
})