-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauth.ts
28 lines (24 loc) · 811 Bytes
/
auth.ts
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
import NextAuth from "next-auth";
import authConfig from "./auth.config";
declare module "next-auth" {
interface Session {
access_token: string;
}
}
export const { handlers, auth, signIn, signOut } = NextAuth({
callbacks: {
async session({ session, token }) {
if (token.access_token) {
session.access_token = token.access_token as string; // Put the provider's access token in the session so that we can access it client-side and server-side with `auth()`
}
return session;
},
async jwt({ token, account }) {
if (account) {
token.access_token = account.access_token; // Store the provider's access token in the token so that we can put it in the session in the session callback above
}
return token;
},
},
...authConfig,
});