繁体   English   中英

SONOS 身份验证令牌未在授权 HTTP header 中发送,用于 CQ API 调用

[英]SONOS auth token is not being sent in Authorization HTTP header for CQ API calls

我按照Sonos 文档添加应用程序身份验证使用身份验证令牌的页面,结果是 SMAPI 服务器正确地将 authToken 和 privateKey 返回到 controller。 我可以看到发送到我的 SMAPI 服务器的 SOAP 消息中的凭据 header 中存在 authToken。

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身份。

我尝试了以下方法,但没有成功:

  • 在我的 Sonos 设备的海关页面中检查“需要授权标头”功能(我尝试了此操作,因为有关功能的文档页面准确地表明检查此“在 HTTP 授权 Z099FB995346F031C7E3ZF64 中检查此“发送 OAuth 令牌”

  • 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,我找不到任何可以基于此识别用户的信息)

从 Sonos 设备:

X-Sonos-Playback-Id: RINCON_48??????D201400:3165321802 <= deviceId 在 RINCON_ 之后插入

X-Sonos-Device-Id:Sonos_U????????????????????????6 <= homeId

X-Sonos-Corr-Id: 267e3e0c-75ca-4b9d-8be4-b8a795a462a3 <= 每次唯一

从 macOS Controller:

X-Sonos-Controller-ID: 68:??:??:??:??:07 <= 每次都相同

X-Sonos-Api-Key:8??????e-7??7-4??fb??6-7??????????0 <= 每次都相同

X-Sonos-Corr-Id:648ec896-e043-44f8-bfba-cd0a80c9d857 <= 每次唯一

我上面提到的文档链接提到了 HTTP 授权 header 中存在的身份验证令牌如下:

  • GET /context CQ API 方法页面显示访问令牌已过期或无效”时返回 401 Unauthorized。

  • GET /itemWindows CQ API 方法页面显示“玩家可以使用此 API 从您的云队列服务器的响应中获取新的访问令牌“请求包含授权标头中的访问令牌“如果访问令牌即将到期,更新的包含在响应的 X-Updated-Authorization header 中”

  • 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"

  • GET /version CQ API 方法页面再次说“请求在授权标头中包含访问令牌并谈到现在不推荐使用的updateToken参数,并且还说“如果访问令牌设置为即将过期,您应该包含一个X-Updated-Authorization header 中的更新令牌。”

但最清楚的提及是在关于 HTTP 请求的页面中,因为它不仅适用于 CQ API 端点,而且适用于所有 HTTP 端点本身托管的服务器。SMAPI 该页面读取以下2个摘录:

第一次扩展提及

第二次扩展提及

总而言之,在Sonos官方文档中提到了这么多,为什么这个重要的header没有在HTTP授权header中传输? 在每个 API 方法请求中不存在此 authToken 的情况下,CQ 应该如何验证请求者的身份?

如果我没听错的话,令牌会在 loginToken 下的 header 中传递,请参阅https://developer.sonos.com/build/content-service-add-features/add-authentication/use-authentication-tokens/

这不是 http header,这是 SOAP 信封的一部分。 像这样:

在此处输入图像描述

身份验证令牌是敏感信息,如果将其发送到不安全的端点,则不会包含在 HTTP 标头中。

使用https://地址后面的 CQ 服务器重试。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM