Browse Source

Make Spotify callback configurable

Toni Fadjukoff 6 years ago
parent
commit
5185963f8b
2 changed files with 4 additions and 3 deletions
  1. 2 1
      bot.go
  2. 2 2
      spotify/spotify.go

+ 2 - 1
bot.go View File

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

+ 2 - 2
spotify/spotify.go View File

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