sonos-controller | Java API for controlling SONOS players | Audio Utils library
kandi X-RAY | sonos-controller Summary
kandi X-RAY | sonos-controller Summary
Java API for controlling SONOS players
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Clips the current music
- Get the current track information
- Pauses the current instance
- Get the play state of the device
- Gets a queue of tracks from the server
- Creates a new content directory
- Find all occurrences of a given regular expression
- Parses track metadata
- Sets the play mode for the queue
- Get the bass value
- Turns the night mode
- Mute or unmute the sound
- Changes the led state
- Returns the play mode of the queue
- Returns the treble s treble
- Play a single item from a queue
- Get all SONOS devices on the network
- Returns true if soundness is activated
- Change the speaker s input
- Discover a single SONOS speaker
- Sets the bass value
- Switch to line input
- Returns true if the speaker is a group coordinator or not
- Get the current volume
- Remove a track from a queue
- Set the treble value
sonos-controller Key Features
sonos-controller Examples and Code Snippets
git clone https://github.com/vmichalak/sonos-controller.git
cd sonos-controller
git submodule init
git submodule update
List devices = SonosDiscovery.discover();
SonosDevice sonos = new SonosDevice("10.0.0.102");
sonos.pause();
Community Discussions
Trending Discussions on sonos-controller
QUESTION
I followed the Sonos docs for adding app authentication and the page for using authentication tokens and the result is that the SMAPI server correctly returns an authToken together with a privateKey back to the controller. I can see the authToken being present in the credentials header inside the SOAP messages sent to my SMAPI server.
However, despite the many mentions of this inside the Sonos docs pages related to HTTP requests (I will list the resources links down below), the same authToken is not being sent inside the HTTP header Authorization, this making my CQ server unable to validate requester identity.
I tried the following, without success:
checking "Requires authorization header" capability in the customsd page of my Sonos device (I tried this because the docs page about capabilities precisely indicates that checking this "Sends OAuth token in the HTTP Authorization header.")
identifying some correlation between the "X-Sonos-" prefix HTTP headers used when the controller sends SOAP messages to my SMAPI server and the "X-Sonos-" prefix HTTP headers used when the device sends HTTP requests to my CQ server (eventually, I could not find any information that would identify the user based on this)
From Sonos device:X-Sonos-Playback-Id: RINCON_48??????D201400:3165321802 <= deviceId inserted after RINCON_
X-Sonos-Device-Id: Sonos_U????????????????????????6 <= householdId
X-Sonos-Corr-Id: 267e3e0c-75ca-4b9d-8be4-b8a795a462a3 <= unique each time
From macOS Controller:X-Sonos-Controller-ID: 68:??:??:??:??:07 <= the same each time
X-Sonos-Api-Key: 8??????e-7??7-4??f-b??6-7??????????0 <= the same each time
X-Sonos-Corr-Id: 648ec896-e043-44f8-bfba-cd0a80c9d857 <= unique each time
- checking both "Include SMAPI context headers with all requests" and "Include Zone Player IDs in credentials header" capabilities in the customsd page of my Sonos device (I tried this following the answer to this sonos tagged stackoverflow question Now that device ID is deprecated, is there another way to identify the client?)
The docs links I mentioned above that refer the presence of the auth token inside the HTTP Authorization header are the following:
the GET /context CQ API method page says to return 401 Unauthorized when "The access token has expired or is invalid."
the GET /itemWindows CQ API method page says "the player can use this API to obtain a new access token in the response from your cloud queue server" and "The request contains the access token in the authorization header" and "If the access token is set to expire soon, an updated one is included in the X-Updated-Authorization header of the response"
the POST /timePlayed CQ API method page says "The request header contains the access token in the authorization header" and that the method returns ERROR_SONOS_TOKEN_EXPIRED when "SMAPI OAuth token is expired, and user must re-authorize the account"
the GET /version CQ API method page says again that "The request contains the access token in the authorization header" and talks about a now deprecated updateToken parameter and also says that "If the access token is set to expire soon, you should include an updated token in the X-Updated-Authorization header."
But the most clear mention is in the page about HTTP requests, because it's not particular just for the CQ API endpoints but for all HTTP endpoints, even those hosted by the SMAPI server itself. The page reads the following 2 excerpts:
and
To conclude, with so many mentions of it in the official Sonos docs, why isn't this essential header being transmitted in the HTTP Authorization header? And how should a CQ verify the identity of the requester without the presence of this authToken on each API method request?
...ANSWER
Answered 2021-May-09 at 22:26If I follow you correctly, the token is passed in the header under loginToken, see https://developer.sonos.com/build/content-service-add-features/add-authentication/use-authentication-tokens/
This is not an http header, this is a section of the SOAP envelope. Like this:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install sonos-controller
You can use sonos-controller like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the sonos-controller component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page