Przeglądaj źródła

Make Spotify callback configurable

Toni Fadjukoff 6 lat temu
rodzic
commit
5185963f8b
2 zmienionych plików z 4 dodań i 3 usunięć
  1. 2 1
      bot.go
  2. 2 2
      spotify/spotify.go

+ 2 - 1
bot.go Wyświetl plik

@@ -30,12 +30,13 @@ type Credentials struct {
30 30
 	SpotifyClientID     string
31 31
 	SpotifyClientSecret string
32 32
 	SpotifyUser         string
33
+	SpotifyCallback     string
33 34
 	ListenAddr          string
34 35
 }
35 36
 
36 37
 func (app *App) CreateSpotifyClient() *spotify.SpotifyClient {
37 38
 	spotifyClient := spotify.NewClient(app.credentials.SpotifyClientID, app.credentials.SpotifyClientSecret)
38
-	spotifyClient.SetupUserAuthenticate()
39
+	spotifyClient.SetupUserAuthenticate(app.credentials.SpotifyCallback)
39 40
 	return spotifyClient
40 41
 }
41 42
 

+ 2 - 2
spotify/spotify.go Wyświetl plik

@@ -164,11 +164,11 @@ func (s *SpotifyClient) Authenticate() error {
164 164
 	return nil
165 165
 }
166 166
 
167
-func (s *SpotifyClient) SetupUserAuthenticate() error {
167
+func (s *SpotifyClient) SetupUserAuthenticate(redirectURL string) error {
168 168
 	s.config = &oauth2.Config{
169 169
 		ClientID:     s.clientID,
170 170
 		ClientSecret: s.clientSecret,
171
-		RedirectURL:  "http://localhost:8080/callback",
171
+		RedirectURL:  redirectURL,
172 172
 		Scopes:       []string{"playlist-modify-public"},
173 173
 		Endpoint:     spotifyAuth.Endpoint,
174 174
 	}