here-api - 为什么我会收到“签名不匹配。授权签名或事物凭证错误”?
问题描述
尝试为设备生成令牌,得到“”签名不匹配。授权签名或事物凭证错误”不确定我做错了什么
发送带有标头的 POST 请求:Content-Type: application/json Authorization: OAuth oauth_consumer_key="ac85020f-c352-4ac9-853e-4b64f3645463", oauth_signature_method="HMAC-SHA256", oauth_timestamp="1558262091", oauth_nonce="LIIBLApk88 ", oauth_version="1.0", oauth_signature="e894d7545b903c16723c1051305828efc52623da534197a50d782f82b9f0149c"
the oauth signature is HMAC-SHA256 of: POST&https%3A%2F%2Ftracking.api.here.com%2Fv2%2Ftoken&oauth_consumer_key%3Dac85020f-c352-4ac9-853e-4b64f3645463%26oauth_nonce%3DLIIBLApk5%26oauth_signature_method%3DHMAC-SHA256%26oauth_timestamp%3D1558260025 %26oauth_version%3D1.0
签名:{设备密码}&
并得到:{“code”:401,“id”:“624b4eb2-7838-450d-8c5c-363c3df4f308”,“message”:“签名不匹配。授权签名或事物凭据错误。”,“错误”:“时间戳错误\n\n当请求时间戳与服务器时间相差超过10秒时,将x-here-timestamp
带有当前服务器\n时间戳的标头添加到响应中。\n\n签名不正确\n\n如果OAuth签名不正确,响应将是 401 但\n没有该x-here-timestamp
字段。\n" }
并且时间戳没有错
解决方案
您的 oauth 签名中缺少一些内容。我遇到过同样的问题。它应该看起来像
POST&https%3A%2F%2Faccount.api.here.com%2Foauth2%2Ftoken&grant_type%3Dclient_credentials%26oauth_consumer_key%3Dxxxxxxxxxxxxxxxx%26oauth_nonce%3D5e5c338b14198%26oauth_signature_method%3DHMAC-SHA256%26oauth_timestamp%3D1583100811%26oauth_version%3D1.0
您在 'token&' 之后缺少 grant_type%3Dclient_credentials
推荐阅读
- android - 将附件从 Android 设备自动发送到另一台设备
- java - 安排一个每天运行 2 次的任务
- python - Python 中的 JSON 导航(PowerBI API)
- javascript - 如何在 Svelte 中重做 {#await ...}?
- python - OpenCV 的 label2rgb 实现
- python - 如何使用 Keras 执行离线图像增强?
- case - Verilog 案例陈述始终为真
- sql - 如何在 SQL Server 中使用脚本安排作业?
- html - CSS样式不适用于
- visual-studio-code - 错误:stylelint 警告的“严重性”属性必须是“错误”或“警告”,但它是“忽略”(字符串)