added saving and refreshing token

This commit is contained in:
2025-11-23 22:35:45 +00:00
parent 09106ccb75
commit c6aac050cc
3 changed files with 89 additions and 7 deletions

View File

@@ -3,6 +3,7 @@ package handlers
import (
"net/http"
"adam-french.co.uk/backend/services"
"github.com/gin-gonic/gin"
"github.com/zmb3/spotify/v2"
)
@@ -17,7 +18,7 @@ func (store *Store) CompleteAuth(c *gin.Context) {
return
}
store.SpotifyToken = token
services.SaveSpotifyToken(services.SPOTIFY_TOKEN_JSON_PATH, token)
client := spotify.New(store.SpotifyAuth.Client(c.Request.Context(), token))

View File

@@ -3,13 +3,11 @@ package handlers
import (
"github.com/zmb3/spotify/v2"
spotifyauth "github.com/zmb3/spotify/v2/auth"
"golang.org/x/oauth2"
"gorm.io/gorm"
)
type Store struct {
DB *gorm.DB
SpotifyAuth *spotifyauth.Authenticator
SpotifyToken *oauth2.Token
SpotifyClient *spotify.Client
}