azure - 错误: The received token is of incorrect token type -- What should the token look like?

标签 azure azure-cognitive-services

我最近注册了 Microsoft Azure 并设置了认知服务帐户。使用 Text Translation API Documentation 中的说明我能够使用 interactive online example/issueToken 服务检索身份验证 token 。但是,如果我想使用该 token (例如 interactive /translate example ),我最终会得到响应

<html><body><h1>Argument Exception</h1><p>Method: Translate()</p><p>Parameter: </p><p>Message: The received token is of incorrect token type.</p><code></code><p>message id=0344.V2_Rest.Translate.3D8A6FF1</p></body></html>

我做错了什么? token 应该是什么样子以及我应该以什么格式提供它?在在线示例中,我通过将 appid 字段设置为“Bearer [token]”来指定 token ,其中 [token] 是来自 < em>/issueToken.

在我的例子中, token 是一个 687 个字符长的字符串,可以分为三个部分(使用“.”作为分隔符)。前两部分是 base64 编码的,只包含一些保持不变的 JSON 编码信息(过期日期字段除外)。第三部分也是最后一部分每次都会发生变化,并且无法使用 base64 进行解码。我没有提供完整的 token ,而是尝试仅使用完整 token 的各种子字符串,但到目前为止没有任何成功。

我还尝试使用身份验证 header 而不是appid字段通过curl进行身份验证,这对我来说也不起作用。

最佳答案

token 实际上必须看起来像问题文本中所描述的那样(至少到目前为止)。我的问题是我使用了错误的订阅 key 。请注意:您为翻译 API 和语音 API 分别获得不同的 key ;即使两者都在认知服务下运行并且即使您通过相同的资源连接两者。

我发布此内容作为我的问题的答案,因为我想确认上面列出的所有步骤都是正确的,并且因为我希望它可以帮助那些犯了与我相同错误的人。

关于azure - 错误: The received token is of incorrect token type -- What should the token look like?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40788259/

相关文章:

azure-cognitive-services - 尝试从 Azure 添加 key 时参数错误、订阅 key 无效

Javascript 调用文本分析返回 HTTP 400 错误请求错误

linux - 需要将 azure VM OS 磁盘大小从 32 GB 调整为 16 GB

php - 使用php将csv上传到windows azure存储

python - Azure 机器学习 Python 模块无法执行对认知服务的调用

Azure 认知服务内容监视器无法检测英国电话号码

python - Azure Face API,python SDK属性url

azure - 如何更改我的 Azure 订阅的管理证书?

c# - 无法保存引用类型

c# - 删除我的 mvc 应用程序中的自定义错误?