mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-25 05:47:57 +02:00
Use config from OAuth2Authenticator for auth command
This commit is contained in:
parent
cf3747bde2
commit
d0739aad0f
5 changed files with 31 additions and 18 deletions
15
cmd/auth.go
15
cmd/auth.go
|
@ -25,9 +25,9 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"go.uploadedlobster.com/scotty/backends"
|
||||
"go.uploadedlobster.com/scotty/models"
|
||||
"go.uploadedlobster.com/scotty/storage"
|
||||
"golang.org/x/oauth2"
|
||||
"golang.org/x/oauth2/spotify"
|
||||
)
|
||||
|
||||
// authCmd represents the auth command
|
||||
|
@ -37,19 +37,14 @@ var authCmd = &cobra.Command{
|
|||
Long: `For backends requiring authentication this command can be used to authenticate.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
serviceName, serviceConfig := getConfigFromFlag(cmd, "service")
|
||||
backend := serviceConfig.GetString("backend")
|
||||
backend, err := backends.ResolveBackend[models.OAuth2Authenticator](serviceConfig)
|
||||
cobra.CheckErr(err)
|
||||
|
||||
redirectURL, err := backends.BuildRedirectURL(viper.GetViper(), backend)
|
||||
redirectURL, err := backends.BuildRedirectURL(viper.GetViper(), backend.Name())
|
||||
cobra.CheckErr(err)
|
||||
|
||||
ctx := context.Background()
|
||||
conf := &oauth2.Config{
|
||||
ClientID: serviceConfig.GetString("client-id"),
|
||||
ClientSecret: serviceConfig.GetString("client-secret"),
|
||||
Scopes: []string{"user-read-recently-played"},
|
||||
RedirectURL: redirectURL.String(),
|
||||
Endpoint: spotify.Endpoint,
|
||||
}
|
||||
conf := backend.OAuth2Config(redirectURL)
|
||||
|
||||
responseChan := make(chan string)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue