-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth.ts
More file actions
34 lines (33 loc) · 1.03 KB
/
auth.ts
File metadata and controls
34 lines (33 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import NextAuth from "next-auth";
import Spotify from "next-auth/providers/spotify";
export const { handlers, signIn, signOut, auth } = NextAuth({
providers: [
Spotify({
authorization: {
url: "https://accounts.spotify.com/authorize",
params: {
scope: "user-read-email user-read-private playlist-read-private playlist-read-collaborative playlist-modify-private playlist-modify-public",
},
},
clientId: process.env.AUTH_SPOTIFY_ID || "",
clientSecret: process.env.AUTH_SPOTIFY_SECRET || "",
}),
],
session: {
strategy: "jwt",
},
callbacks: {
async jwt({ token, account }) {
if (account) {
token.access_token = account.access_token;
}
return token;
},
async session({ session, token }) {
return {
...session,
accessToken: token.access_token,
};
},
},
});