Implementing Authentication

Providing for new user accounts to your service

If the user does not have an account with your service, you can choose to provide the user with a link to create one. In your response to getAppLink, include the <createAccount> element. This instructs the Sonos app to present to the user a button for opening your app and creating an account on your service. The following shows the Sonos app screens to initiate this process:

When the user selects "Add Account", the Sonos app sends your service a getAppLink request. In order for your service to provide the two options shown in the right-most screen, your service's response to getAppLink should be similar to the following. The <appUrl> of <authorizeAccount> provides the link into your app's sign-in workflow, and the <appUrl> of <createAccount> provides the link into your app's new-account workflow. 

. . .
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.sonos.com/Services/1.1">
   <s:Body>
      <getAppLinkResponse>
         <getAppLinkResult xsi:type="appLinkResult" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <authorizeAccount>
               <appUrl>acme-action://authorize?scope=browse,playback,favorites&client_id=9b377073ea334637b1406f329ce005de&response_type=code&state=sid%3D3079%26OAuthDeviceID%3DSonos_J9zl49YnRMtvgEYHPb4hJKvqYd_7d55e99%26callbackPath%3D%2FaddAccount&redirect_uri=sonos%3A%2F%2Fx-callback-url%2FaddAccount</appUrl>
               <appUrlStringId>SIGN_IN</appUrlStringId>
               <deviceLink>
                  <regUrl>https://oauth.acme.com/home?linkCode=AKVS3FHEAUCXAQKLkMA</regUrl>
                  <linkCode>AKVS3FHEAUCXAQKLkMA</linkCode>
                  <showLinkCode>false</showLinkCode>
               </deviceLink>
            </authorizeAccount>
            <createAccount>
               <appUrl>acme-action://newAccount?scope=browse,playback,favorites&client_id=9b377073ea334637b1406f329ce005de&response_type=code&state=sid%3D3079%26OAuthDeviceID%3DSonos_J9zl49YnRMtvgEYHPb4hJKvqYd_7d55e99%26callbackPath%3D%2FaddAccount&redirect_uri=sonos%3A%2F%2Fx-callback-url%2FaddAccount</appUrl>
               <appUrlStringId>CREATE_NEW</appUrlStringId>
            </createAccount>
         </getAppLinkResult>
      </getAppLinkResponse>
   </s:Body>
</s:Envelope>

We encourage you to direct users to your app for both the sign-in and create-account workflows. However, if the user does not have the app installed, Sonos will use the sign-in URL you provided to Sonos in the version manager (see Listing your music service in the Service Catalog for details). If you want to restrict the user to create an account using only a Web page and not your app, leave out the <appUrl> sub-element in the <createAccount> element:

. . .
      <createAccount>
         <appUrlStringId>CREATE_NEW</appUrlStringId>
      </createAccount>
. . .

You can still include the <appUrlStringId> element if you don't provide <appUrl>. This way you can still customize the signup button.