adding auth
This commit is contained in:
@@ -1,34 +1,9 @@
|
|||||||
package services
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/zmb3/spotify/v2"
|
"github.com/zmb3/spotify/v2"
|
||||||
spotifyauth "github.com/zmb3/spotify/v2/auth"
|
|
||||||
"golang.org/x/oauth2/clientcredentials"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func InitSpotify() (*spotify.Client, error) {
|
func InitSpotify() *spotify.Client {
|
||||||
ctx := context.Background()
|
return nil
|
||||||
|
|
||||||
// redirectURI := os.Getenv("SPOTIFY_REDIRECT_URI")
|
|
||||||
clientID := os.Getenv("SPOTIFY_CLIENT_ID")
|
|
||||||
clientSecret := os.Getenv("SPOTIFY_CLIENT_SECRET")
|
|
||||||
|
|
||||||
config := &clientcredentials.Config{
|
|
||||||
ClientID: clientID,
|
|
||||||
ClientSecret: clientSecret,
|
|
||||||
TokenURL: spotifyauth.TokenURL,
|
|
||||||
}
|
|
||||||
|
|
||||||
token, err := config.Token(context.Background())
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
httpClient := spotifyauth.New().Client(ctx, token)
|
|
||||||
client := spotify.New(httpClient)
|
|
||||||
|
|
||||||
return client, nil
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user