Det9999 commited on
Commit
53bff8d
·
verified ·
1 Parent(s): 71b697b

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

Browse files
Files changed (1) hide show
  1. pages/api/auth/login.js +27 -0
pages/api/auth/login.js ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export default function handler(req, res) {
2
+ const { clientId, redirectUri } = req.body;
3
+
4
+ if (!clientId) {
5
+ return res.status(400).json({ error: 'Missing Client ID' });
6
+ }
7
+
8
+ const scopes = [
9
+ 'user-read-private',
10
+ 'user-read-email',
11
+ 'user-top-read',
12
+ 'user-library-read',
13
+ 'playlist-read-private'
14
+ ];
15
+
16
+ const params = new URLSearchParams({
17
+ client_id: clientId,
18
+ response_type: 'code',
19
+ redirect_uri: redirectUri,
20
+ scope: scopes.join(' '),
21
+ show_dialog: true
22
+ });
23
+
24
+ const authUrl = `https://accounts.spotify.com/authorize?${params.toString()}`;
25
+
26
+ res.status(200).json({ url: authUrl });
27
+ }