Closed tcurdt closed 5 years ago
I don't quite understand why this is giving an "unauthorized" error. What am I missing? The credentials work fine for some other client.
package main import ( "context" "fmt" "log" "github.com/zmb3/spotify" "golang.org/x/oauth2/clientcredentials" ) func main() { config := &clientcredentials.Config{ ClientID: os.Getenv("SPOTIFY_ID"), ClientSecret: os.Getenv("SPOTIFY_SECRET"), TokenURL: spotify.TokenURL, } token, err := config.Token(context.Background()) if err != nil { log.Fatalf("couldn't get token: %v", err) } client := spotify.Authenticator{}.NewClient(token) page, err := client.CurrentUsersPlaylists() if err != nil { log.Fatalf("couldn't get playlists: %v", err) } for _, playlist := range page.Playlists { fmt.Println(" ", playlist.Name) } }
OK, so this needs the authorization code flow to provide the proper scopes.
I don't quite understand why this is giving an "unauthorized" error. What am I missing? The credentials work fine for some other client.