未经授权(错误401)邮递员 [英] Unauthorized (Error 401) Postman

查看:71
本文介绍了未经授权(错误401)邮递员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过PostMan Chrome应用程序将推送通知(使用Firebase平台)发送到我的Android应用程序,但是我无法使其工作.我已经按照有关连接它的所有说明进行操作,但是它不起作用.我看到这不是一个异常问题,因此我已经检查了

当我按SEND到我的应用程序时,它显示未经授权和错误401.很明显,问题出在哪里,但我不知道如何解决.在Firebase控制台和* .JSON文件中,授权密钥都是相同的,而正文包含以下内容:

  {至":"/topics/NEWS",数据": {"extra_information":这是一些额外的信息"},通知": {"title":新通知!","text":点击我打开活动!","click_action":"SOMEACTIVITY"}}  

我什至试图在之后添加密钥到:

从JSON文件中提取的内容如下所示:没事.有人可以帮我吗?我是否需要使用JSON文件中的其他代码?帮助吗?

解决方案

授权标头中指定的密钥必须是项目设置> Cloud Messaging 的Firebase控制台标签.项目设置>常规标签上显示的Web API密钥不起作用.

此外,通知文本的属性是 body ,而不是 text :

  {至":"/topics/NEWS",数据": {"extra_information":这是一些额外的信息"},通知": {"title":新通知!","body":点击我打开活动!",//< =已更改"click_action":"SOMEACTIVITY"}} 

I am trying to send Push Notifications (using Firebase platform) to my Android app through PostMan Chrome App, but I fail to make it work. I have followed all the instructions on connecting it, but it doesn't work. I can see that this is not an unusual problem, and therefore I have checked this, this, this and many more. Some console layouts/settings have changed and it's not that easy to follow ad literam, but I can see that the Authorization key is the secret.

However, even with all the check-ups and changes I have this:

When I'm pressing on SEND to my app, it gives Unauthorized and Error 401. It is obvious what the problem is, but I don't know how to solve it. The Authorization key is the same both in the Firebase console and in the *.JSON file, while the body contains this:

{
  "to": 
    "/topics/NEWS"
  ,
  "data": {
    "extra_information": "This is some extra information"
  },
  "notification": {
    "title": "NEW NOTIFICATION!",
    "text": "Click me to open an Activity!",
    "click_action": "SOMEACTIVITY"
  }
}

I even tried to add the key after to:

And extract from the JSON file can be seen below: Nothing worked. Can anyone help me with this, please? Do I need to use some other code from the JSON file? Help?

解决方案

The key specified in the authorization header must be the Server key or Legacy Server key shown in the Firebase console tab for Project Settings > Cloud Messaging. The Web API key shown on the Project Settings > General tab will not work.

Also, the property for the notification text is body, not text:

{
  "to": 
    "/topics/NEWS"
  ,
  "data": {
    "extra_information": "This is some extra information"
  },
  "notification": {
    "title": "NEW NOTIFICATION!",
    "body": "Click me to open an Activity!", // <= CHANGED
    "click_action": "SOMEACTIVITY"
  }
}

这篇关于未经授权(错误401)邮递员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆