Spaces:
Runtime error
Runtime error
Upload pages/api/auth/[...nextauth].js with huggingface_hub
Browse files
pages/api/auth/[...nextauth].js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import NextAuth from 'next-auth';
|
| 2 |
+
import GoogleProvider from 'next-auth/providers/google';
|
| 3 |
+
import GitHubProvider from 'next-auth/providers/github';
|
| 4 |
+
|
| 5 |
+
export const authOptions = {
|
| 6 |
+
providers: [
|
| 7 |
+
GoogleProvider({
|
| 8 |
+
clientId: process.env.GOOGLE_CLIENT_ID || 'mock-google-id',
|
| 9 |
+
clientSecret: process.env.GOOGLE_CLIENT_SECRET || 'mock-google-secret',
|
| 10 |
+
}),
|
| 11 |
+
GitHubProvider({
|
| 12 |
+
clientId: process.env.GITHUB_ID || 'mock-github-id',
|
| 13 |
+
clientSecret: process.env.GITHUB_SECRET || 'mock-github-secret',
|
| 14 |
+
}),
|
| 15 |
+
],
|
| 16 |
+
pages: {
|
| 17 |
+
signIn: '/auth/signin',
|
| 18 |
+
error: '/auth/error',
|
| 19 |
+
},
|
| 20 |
+
callbacks: {
|
| 21 |
+
async jwt({ token, account }) {
|
| 22 |
+
if (account) {
|
| 23 |
+
token.accessToken = account.access_token;
|
| 24 |
+
}
|
| 25 |
+
return token;
|
| 26 |
+
},
|
| 27 |
+
async session({ session, token }) {
|
| 28 |
+
session.accessToken = token.accessToken;
|
| 29 |
+
return session;
|
| 30 |
+
},
|
| 31 |
+
},
|
| 32 |
+
secret: process.env.NEXTAUTH_SECRET,
|
| 33 |
+
};
|
| 34 |
+
|
| 35 |
+
export default NextAuth(authOptions);
|