Last active
October 11, 2022 19:38
-
-
Save balazsorban44/a8e6f522ebd54da2a90a588d8967fd95 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//... | |
providers: [ | |
Twitch({ | |
clientId: process.env.TWITCH_ID, | |
clientSecret: process.env.TWITCH_SECRET, | |
authorization: { params: { scope: "openid user:read:email moderation:read" } }, | |
async profile(profile, tokens) { | |
const id = profile.sub | |
const res = await fetch(`https://api.twitch.tv/helix/users?id=${id}}`, { | |
headers: { Authorization: `Bearer ${tokens.access_token}`, "Client-Id": process.env.TWITCH_ID }, | |
}) | |
const { data: [user] } = await res.json() | |
return { | |
id, | |
name: profile.preferred_username, | |
email: profile.email, | |
image: profile.picture, | |
description: user.description, | |
} | |
}, | |
}), | |
], | |
callbacks: { | |
jwt({ token, user }) { | |
token.description ??= user.description | |
return token | |
}, | |
session({ session, token }) { | |
session.user.description = token.description | |
return session | |
}, | |
} | |
// ... | |
declare module "next-auth/jwt" { | |
interface JWT { description: string } | |
} | |
declare module "next-auth" { | |
interface User { description: string } | |
interface Session {user: User } | |
} | |
// ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment