【问题标题】:Sonos Music API getDeviceAuthToken retry responses not workingSonos 音乐 API getDeviceAuthToken 重试响应不起作用
【发布时间】:2020-08-12 22:05:00
【问题描述】:

我们已经在customsd page 上注册了我们的服务,我们可以从Add Music Services 菜单选项中选择它。但是,我们在授权过程中遇到了一些困难。

当我们开始登录过程时,Sonos 向我们的服务发出getAppLink 请求,我们做出响应,按钮成功将用户带到我们的登录页面。那件作品似乎正在发挥作用。

但是,Sonos 正在进行的getDeviceAuthToken 轮询存在问题。登录过程开始后,Sonos 会持续发送三个 getDeviceAuthToken 请求,然后放弃,即使我们返回了必要的重试响应,也不再发送请求。

来自 Sonos 的请求如下所示(部分或全部编辑了一些信息,并在正文中添加了格式以提高可读性):

POST <our_soap_endpoint> HTTP/1.1
Connection: Keep-Alive
Content-Type: text/xml; charset="utf-8"
Accept-Encoding: gzip
Accept-Language: en-US
Host: <our_site>
Max-Forwards: 10
User-Agent: Linux UPnP/1.0 Sonos/51.1-67300 (ICRU_iPhone11,8)
X-Sonos-Controller-ID: 02A4****
X-Sonos-Api-Key: 4348****
X-Sonos-Corr-Id: 0b99****
SOAPACTION: "http://www.sonos.com/Services/1.1#getDeviceAuthToken"
X-FORWARDED-PROTO: https
X-FORWARDED-PORT: 443
X-ORIGINAL-HOST: <our_site>
X-Original-URL: <our_soap_endpoint>
X-Forwarded-For: <some_ip_address>
X-ARR-SSL: 2048|256|C=US, O=DigiCert Inc, CN=DigiCert SHA2 Secure Server CA|C=US, S=Ohio, L=Cleveland, O="OverDrive, Inc.", OU=OverDrive IT, CN=*.overdrive.com
X-ARR-LOG-ID: 5188****
Content-Length: 548

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Header>
        <credentials xmlns="http://www.sonos.com/Services/1.1">
            <deviceId>78****</deviceId>
            <deviceProvider>Sonos</deviceProvider>
        </credentials>
        <context xmlns="http://www.sonos.com/Services/1.1">
            <timeZone>-4:00</timeZone>
        </context>
    </s:Header>
    <s:Body>
        <getDeviceAuthToken xmlns="http://www.sonos.com/Services/1.1">
            <householdId>Sonos_sIGu****</householdId>
            <linkCode>ab76****</linkCode>
        </getDeviceAuthToken>
    </s:Body>
</s:Envelope>

我们的回复看起来像这样(再次部分或全部编辑了一些信息,并在正文中添加了格式以提高可读性):

HTTP/1.1 500 Internal Server Error
Transfer-Encoding: chunked
Content-Type: text/xml; charset="utf-8"
Server: Microsoft-IIS/10.0
Date: Fri, 30 Aug 2019 13:25:25 GMT

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
        <s:Fault>
            <faultcode>Client.NOT_LINKED_RETRY</faultcode>
            <faultstring>No token found for link code ab76****. Please retry.</faultstring>
        </s:Fault>
    </s:Body>
</s:Envelope>

根据getDeviceAuthTokenerror handling / faults 的文档我们可以看出,我们的回复似乎与告诉Sonos 重试的预期相符。我们是否遗漏了什么或做错了什么?

【问题讨论】:

    标签: sonos


    【解决方案1】:

    您的回复看起来不正确。应该是这样的:

    . . .
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.sonos.com/Services/1.1">
       <soap:Body>
          <soap:Fault>
             <faultcode>Client.NOT_LINKED_FAILURE</faultcode>
             <faultstring>Access to token failed</faultstring>
             <detail>
                <ns:ExceptionInfo>Restart authentication.</ns:ExceptionInfo>
                <ns:SonosError>6</ns:SonosError>
             </detail>
          </soap:Fault>
       </soap:Body>
    </soap:Envelope>
    

    详情请见HANDLING ERRORS DURING AUTHENTICATION

    【讨论】:

    • 谢谢。但是我对到底是什么问题感到有些困惑。我只看到了一些区别: • 我们使用s 作为命名空间标识符,但我认为这不重要吗? • 我们将发回Client.NOT_LINKED_RETRY 代码。但是Implementing Authentication page 似乎表明这是我们应该做的,除非身份验证最终失败。 • 我们不包括&lt;detail&gt; 元素。但是这个Error Handling page 说它是可选的。
    • 是的,没错,命名空间标识符可以是您指定的任何内容。但是,在身份验证期间处理错误与在其他情况下处理错误不同。请按照Starting an implementation using browser authentication 页面上“重试对GETDEVICEAUTHTOKEN 的响应”下的步骤操作,包括带有正确&lt;SonosError&gt; 代码的&lt;detail&gt; 元素。让我知道这是否成功,因为我会在上面更新我的答案。
    • 对延迟回复表示歉意。使用&lt;SonosError&gt; 代码添加&lt;detail&gt; 元素似乎可以让事情正常进行。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-30
    • 2012-02-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多