pradipp commited on
Commit
0cc7f94
·
verified ·
1 Parent(s): 6f7da7e

Upload pages/api/auth/google.js with huggingface_hub

Browse files
Files changed (1) hide show
  1. pages/api/auth/google.js +15 -0
pages/api/auth/google.js ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export default function handler(req, res) {
2
+ const clientId = process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID;
3
+ const redirectUri = `${process.env.NEXTAUTH_URL || 'http://localhost:3000'}/api/auth/callback/google`;
4
+ const scope = 'openid email profile';
5
+
6
+ const authUrl = `https://accounts.google.com/o/oauth2/v2/auth?` +
7
+ `client_id=${clientId}&` +
8
+ `redirect_uri=${encodeURIComponent(redirectUri)}&` +
9
+ `response_type=code&` +
10
+ `scope=${encodeURIComponent(scope)}&` +
11
+ `access_type=offline&` +
12
+ `prompt=consent`;
13
+
14
+ res.redirect(authUrl);
15
+ }