6

【Business Touch Kit】服务号消息发送接口返回401如何解决?

 2 years ago
source link: https://blog.51cto.com/u_14772288/5660112
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

【Business Touch Kit】服务号消息发送接口返回401如何解决?

精选 原创

华为开发者论坛 2022-09-08 08:34:09 博主文章分类:HMS core ©著作权

文章标签 服务号 解决方案 文章分类 其它 移动开发 阅读数230

【Business Touch Kit 简介】

华为服务号(Business Touch Kit)提供给商家对应的服务号,让用户快速发现商家服务,建立用户与商家的互动连接。为您提供华为统一的商家服务号中心,通过服务分发,用户互动连接,多样化的营销工具等,促进商家的商业闭环。

【问题描述】

调用服务号消息发送的接口发起HTTP请求时,返回了401的状态码,如下所示:

【Business Touch Kit】服务号消息发送接口返回401如何解决?_解决方案

请求头参数如下图所示:

【Business Touch Kit】服务号消息发送接口返回401如何解决?_服务号_02

请求体参数如下图所示:

【Business Touch Kit】服务号消息发送接口返回401如何解决?_服务号_03

【解决方案】

1、HTTP请求返回401的状态码,一般情况下都是未授权,身份认证不通过,需要检查access_token是否正确,关于该参数的说明,详细情况请查看如下链接中的说明文档:

 ​https://developer.huawei.com/consumer/cn/doc/development/HMSCore-References/businesstouch_send_msg-0000001053217280#section88192615912​

【Business Touch Kit】服务号消息发送接口返回401如何解决?_服务号_04

2、这个参数是必传的,需要按照开放平台中的要求来获取,获取方式的说明文档如下链接中所示:

 ​https://developer.huawei.com/consumer/cn/doc/development/HMSCore-Guides/open-platform-oauth-0000001053629189#section12493191334711​

3、打开链接会看到,获取access_token的请求参数说明情况如下图:

【Business Touch Kit】服务号消息发送接口返回401如何解决?_解决方案_05

4、其中,client_id和client_secret这两个参数的获取方式详情如下:

首先登录AppGallery Connect官网,如下所示:

 ​https://developer.huawei.com/consumer/cn/service/josp/agc/marketplace/index.html#/​

然后依次点击:控制台--->我的项目--->项目设置,找到对应的应用,如下图所示:

【Business Touch Kit】服务号消息发送接口返回401如何解决?_解决方案_06

这里可以获取到Client ID和Client Secret这两个参数的值,再结合上面文档中的接口说明,请求该接口获取access_token。

按照以上步骤进行操作,就可以解决消息发送的接口返回401的错误啦!

欲了解更多更全技术文章,欢迎访问​ ​https://developer.huawei.com/consumer/cn/forum/?ha_source=zzh​

  • 收藏
  • 评论
  • 分享
  • 举报

Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK