Skip to content

Commit b05e809

Browse files
committed
Fixed redirect URL after token exchange
1 parent 6873ce8 commit b05e809

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

callback.html

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
<!DOCTYPE html>
22
<html>
3-
43
<head>
54
<title>GrooveGraph - Authentication</title>
65
</head>
7-
86
<body>
97
<script>
108
const params = new URLSearchParams(window.location.search);
119
const code = params.get('code');
1210
const state = params.get('state');
13-
11+
1412
if (code && state === sessionStorage.getItem('spotify_auth_state')) {
1513
// Store the code and redirect to main app
1614
sessionStorage.setItem('spotify_auth_code', code);
@@ -21,5 +19,4 @@
2119
}
2220
</script>
2321
</body>
24-
2522
</html>

script.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ class SpotifyAuth {
5959
const response = await fetch('https://accounts.spotify.com/api/token', {
6060
method: 'POST',
6161
headers: {
62-
'Content-Type': 'application/x-www-form-urlencoded'
62+
'Content-Type': 'application/x-www-form-urlencoded',
63+
'Authorization': 'Basic ' + btoa(`${this.config.clientId}:${this.config.clientSecret}`)
6364
},
6465
body: new URLSearchParams({
6566
grant_type: 'authorization_code',
@@ -75,8 +76,10 @@ class SpotifyAuth {
7576
sessionStorage.setItem('spotify_access_token', data.access_token);
7677
sessionStorage.setItem('spotify_refresh_token', data.refresh_token);
7778

78-
window.location.href = '/'; // Redirect to main page
79+
// Change this line to redirect to your actual homepage URL
80+
window.location.href = 'https://itzsudipta.github.io/GrooveGraph/';
7981
} catch (error) {
82+
console.error('Token exchange error:', error);
8083
this.handleError('Authentication failed');
8184
}
8285
}

0 commit comments

Comments
 (0)