首页 > 解决方案 > 为什么我会收到“签名不匹配。授权签名或事物凭证错误”?

问题描述

尝试为设备生成令牌,得到“”签名不匹配。授权签名或事物凭证错误”不确定我做错了什么

发送带有标头的 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" }

并且时间戳没有错

标签: here-api

解决方案


您的 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


推荐阅读