mirror of
https://github.com/gesellix/Bose-SoundTouch.git
synced 2026-08-19 00:56:16 +00:00
Add endpoint for handling Amazon token exchange
This commit is contained in:
@@ -871,9 +871,10 @@ func setupRouter(server *handlers.Server) *chi.Mux {
|
||||
})
|
||||
|
||||
r.Route("/oauth", func(r chi.Router) {
|
||||
r.Post("/device/{deviceID}/music/musicprovider/{sourceID}/token/cs3", server.HandleBoseToken)
|
||||
r.Post("/device/{deviceID}/music/musicprovider/{sourceID}/token", server.HandleBoseLegacyToken)
|
||||
r.Post("/account/{account}/music/musicprovider/{sourceID}/token/cs", server.HandleBoseAccountToken)
|
||||
r.Post("/device/{deviceID}/music/musicprovider/{sourceID}/token/cs1", server.HandleBoseToken)
|
||||
r.Post("/device/{deviceID}/music/musicprovider/{sourceID}/token/cs3", server.HandleBoseToken)
|
||||
r.HandleFunc("/*", server.HandleBoseProxy)
|
||||
})
|
||||
|
||||
|
||||
@@ -102,6 +102,7 @@ POST /mgmt/spotify/prime handlers.(
|
||||
POST /oauth/* handlers.(*Server).HandleBoseProxy-fm
|
||||
POST /oauth/account/{account}/music/musicprovider/{sourceID}/token/cs handlers.(*Server).HandleBoseAccountToken-fm
|
||||
POST /oauth/device/{deviceID}/music/musicprovider/{sourceID}/token handlers.(*Server).HandleBoseLegacyToken-fm
|
||||
POST /oauth/device/{deviceID}/music/musicprovider/{sourceID}/token/cs1 handlers.(*Server).HandleBoseToken-fm
|
||||
POST /oauth/device/{deviceID}/music/musicprovider/{sourceID}/token/cs3 handlers.(*Server).HandleBoseToken-fm
|
||||
POST /setup/backup/{deviceId} handlers.(*Server).HandleBackupConfig-fm
|
||||
POST /setup/devices handlers.(*Server).HandleAddManualDevice-fm
|
||||
|
||||
@@ -14,14 +14,23 @@ import (
|
||||
)
|
||||
|
||||
// HandleBoseToken handles the Bose-specific token refresh request from the speaker.
|
||||
// POST /oauth/device/{deviceID}/music/musicprovider/{sourceID}/token/cs1
|
||||
// POST /oauth/device/{deviceID}/music/musicprovider/{sourceID}/token/cs3
|
||||
func (s *Server) HandleBoseToken(w http.ResponseWriter, r *http.Request) {
|
||||
sourceID := chi.URLParam(r, "sourceID")
|
||||
|
||||
for _, provider := range constants.StaticProviders {
|
||||
if strconv.Itoa(provider.ID) == sourceID && provider.Name == constants.ProviderSpotify {
|
||||
if strconv.Itoa(provider.ID) != sourceID {
|
||||
continue
|
||||
}
|
||||
|
||||
switch provider.Name {
|
||||
case constants.ProviderSpotify:
|
||||
s.HandleBoseSpotifyToken(w, r)
|
||||
return
|
||||
case constants.ProviderAmazon:
|
||||
s.HandleBoseAmazonToken(w, r)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,6 +98,15 @@ func (s *Server) HandleBoseAccountToken(w http.ResponseWriter, r *http.Request)
|
||||
s.HandleBoseSpotifyToken(w, r)
|
||||
}
|
||||
|
||||
// HandleBoseAmazonToken is a stub for Amazon Music OAuth token handling.
|
||||
// POST /oauth/device/{deviceID}/music/musicprovider/20/token/cs1
|
||||
// Amazon Music API integration is not yet implemented.
|
||||
func (s *Server) HandleBoseAmazonToken(w http.ResponseWriter, r *http.Request) {
|
||||
deviceID := chi.URLParam(r, "deviceID")
|
||||
log.Printf("[Amazon] Token request for device %s — Amazon Music not yet supported", deviceID)
|
||||
http.Error(w, "Amazon Music integration not yet supported", http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
// HandleBoseSpotifyToken handles the Bose-specific Spotify token refresh request.
|
||||
// POST /oauth/device/{deviceID}/music/musicprovider/15/token/cs3
|
||||
func (s *Server) HandleBoseSpotifyToken(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Reference in New Issue
Block a user