API在此返回无法识别的Kid

API在此返回无法识别的Kid

本文介绍了API在此返回无法识别的Kid Null错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的cURL请求

  curl https://geocode.search.hereapi.com/v1/geocode?q=5%20Rue%20Daunou%2C%2075000%20Paris%2C%20France -H授权:承载XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" 

这是回应

  {错误":未经授权","error_description":令牌验证失败-无法识别的孩子为空"} 

我不确定发生了什么.我尝试了其他访问密钥.我产生了新的.但是请继续得到相同的错误.

解决方案

访问密钥ID"并不是您需要在 Authorization 标头中发送的令牌,这就是为什么您会收到 令牌验证失败" 的原因.>

访问密钥ID"但是,它是生成OAuth令牌所需的凭据参数之一,另一个参数是访问密钥机密".

如果您尚未保存访问密钥机密,请转到您的

在凭据文件中,请注意最后三行:

  here.access.key.id =已编辑here.access.key.secret = redacted_redacted_redactedhere.token.endpoint.url = https://account.api.here.com/oauth2/token 

然后,我们可以使用Postman生成OAuth令牌:

  • 打开邮递员并创建一个新请求.
  • 方法POST,网址:

    身体"标签

    注意

    为记录起见,以下内容不使用OAuth,而是使用"API密钥":也可以在REST部分下找到,也可以:

      curl https://geocode.search.hereapi.com/v1/geocode?apiKey=<REST-API-KEY>&q=5%20Rue%20Daunou%2C%2075000%20Paris%2C%20France 

    但是地理编码API参考不记录 apiKey 身份验证,这与其他HERE API不同,例如路由,我不会除了偶尔进行卷曲请求实验之外,还建议您使用它.

    This is my cURL request

    curl https://geocode.search.hereapi.com/v1/geocode?q=5%20Rue%20Daunou%2C%2075000%20Paris%2C%20France -H "Authorization: Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXX"
    

    This is the response

    {"error":"Unauthorized","error_description":"Token Validation Failure - unrecognized kid null"}
    

    I am not sure what is going on. I tried different access keys. I generated new ones. But keep getting the same error.

    解决方案

    The "Access Key ID" is not quite the token you need to send in the Authorization header, which is why you get a "Token Validation Failure".

    The "Access Key ID" is however one of the credential parameter that you need, in order to generate the OAuth tokens, the other parameter being the "Access Key Secret".

    If you didn't save the Access Key Secret already, go to your HERE Account Project Management Space and make sure to download the credential file:

    In the credential file, pay attention to the last three lines:

    here.access.key.id = redacted
    here.access.key.secret = redacted_redacted_redacted
    here.token.endpoint.url = https://account.api.here.com/oauth2/token
    

    Then, we can use Postman to generate the OAuth tokens:

    • Open Postman and create a new request.
    • Method POST, url: https://account.api.here.com/oauth2/token
    • Go to the Auth tab and select:
      • Type: OAuth 1.0
      • Add auth data to Request Headers (probably the default choice)
      • Signature Method: HMAC-SHA256
      • Consumer Key: put the here.access.key.id value
      • Consumer Secret: put the here.access.key.secret value
    • Go to the Body tab and select:
      • x-www-form-urlencoded
      • Key: grant_type, Value: client_credentials
    • Send the request. You should receive an access token. That one should work with your curl request.

    Auth tab

    Body tab

    Note

    For the record, the following, not using OAuth but an "API key" to be found under the REST section as well, also works:

    curl https://geocode.search.hereapi.com/v1/geocode?apiKey=<REST-API-KEY>&q=5%20Rue%20Daunou%2C%2075000%20Paris%2C%20France
    

    However the Geocode API Reference does not document the apiKey authentication, unlike other HERE API e.g. Routing, and I would not recommend it besides for occasional experiments with curl requests.

    这篇关于API在此返回无法识别的Kid Null错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 18:10