首页 > 解决方案 > 在 HMS Push Kit API 中获取访问令牌时出错

问题描述

当我使用此 api 获取访问令牌时:

https://oauth-login.cloud.huawei.com/oauth2/v3/token?grant_type=client_credentials&client_id=****&client_secret=*** *

它总是返回

{
    "sub_error": 20001,
    "error_description": "missing required parameter: client_id",
    "error": 1102
}

虽然我发送 client_id 参数

标签: androidapihuawei-mobile-serviceshuawei-developershuawei-push-notification

解决方案


要解决此问题,请确保以下几点

  1. 您正在向服务器发送请求

  2. 确保POSR URL为“https://oauth-login.cloud.huawei.com/oauth2/v3/token”。

  3. 不要在 URL 中包含 post 参数,在 POST 请求的正文中添加以下参数(如果您使用 postman 工具,您可以找到添加参数的字段)

    grant_type=client_credentials

    client_id=您的客户 ID

    client_secret=您的客户密码

有关获取访问令牌的更多详细信息,请参阅以下链接:

https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides-V5/open-platform-oauth-0000001053629189-V5#EN-US_TOPIC_0000001053629189__section12493191334711


推荐阅读