diff --git a/frontend/src/utils/spotifyAuth.js b/frontend/src/utils/spotifyAuth.js index 791ac68..67fc94a 100644 --- a/frontend/src/utils/spotifyAuth.js +++ b/frontend/src/utils/spotifyAuth.js @@ -13,3 +13,28 @@ export const getSpotifyLoginUrl = () => { REDIRECT_URI )}&scope=${scope}`; }; + +export const getAccessTokenFromUrl = () => { + const hash = window.location.hash; + if (hash) { + const params = new URLSearchParams(hash.substring(1)); + return params.get('access_token'); + } + return null; +}; + +export const storeAccessToken = (token) => { + localStorage.setItem('spotify_access_token', token); +}; + +export const getAccessToken = () => { + return localStorage.getItem('spotify_access_token'); +}; + +export const removeAccessToken = () => { + localStorage.removeItem('spotify_access_token'); +}; + +export const isLoggedIn = () => { + return !!getAccessToken(); +};