getDeviceLinkCode

We recommend that you no longer use getDeviceLinkCode.

If your integration uses getDeviceLinkCode, it will continue to work. For new integrations, we recommend that you upgrade to getAppLink. See Add authentication for details.

Sonos makes this request on your secure (HTTPS) endpoint.

Request parameters

NameTypeDescription
householdIdstringThe Sonos household ID requesting the link code.

Response

Include the response in a deviceLinkCodeResult inside a getDeviceLinkCodeResponse element.

NameTypeDescription
regUrlstringA URL that a user should navigate to in order to complete device authentication. Be sure that this page handles script injection.
linkCodestringThe linkCode generated for device authentication.
showLinkCodebooleanWhether or not the link code should be displayed in the Sonos application UI.
linkDeviceIdstring(Optional) A token that is hidden from the user to prevent token phishing.

Sample request

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.sonos.com/Services/1.1">
  <soapenv:Header>
      <ns:credentials>
         <ns:deviceId>00:00:00:00:00</ns:deviceId>
         <ns:deviceProvider>Sonos</ns:deviceProvider>
      </ns:credentials>
   </soapenv:Header>
   <soapenv:Body>
      <ns:getDeviceLinkCode>
         <ns:householdId>Sonos_abc123</ns:householdId>
      </ns:getDeviceLinkCode>
   </soapenv:Body>
</soapenv:Envelope>

Sample response

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <getDeviceLinkCodeResponse xmlns="http://www.sonos.com/Services/1.1">
         <getDeviceLinkCodeResult>
            <regUrl>https://musicService.example.com/oauth?code=KJ12U</regUrl>
            <linkCode>KJ12U</linkCode>
            <showLinkCode>false</showLinkCode>
            <linkDeviceId>123AQ311</linkDeviceId>
         </getDeviceLinkCodeResult>
      </getDeviceLinkCodeResponse>
   </soap:Body>
</soap:Envelope>