android - 获取通知 key 错误 401 gcm https ://android. googleapis.com/gcm/googlenotification

标签 android push-notification google-cloud-messaging

我正在尝试按照来自 http://developer.android.com/google/gcm/notifications.html 的文档从谷歌服务获取通知 key 并且我在客户端生成一个通知 key 但是我遇到了发布请求的问题,错误 401 OK

{
   "operation": "create",
   "notification_key_name": "vitee",
   "registration_ids": ["********"]
   "id_token": "**************************************************"
}

这是我的请求的快照

![在此处输入图片描述][1]

https://lh5.googleusercontent.com/QmTDFWwjkyPtLFVVcTN4IYwkVhHU42wcUKPjpg_E8KSR3ALAXJ2Js-0K2gzlmmOEUXfrGe1TS8s=w1890-h820

最佳答案

您的 projectid header 标签错误,并且使用项目编号而不是 API key 作为值。

所以,

  1. project_id改成Authorization作为名称
  2. 作为值 key=YOUR_PROJECT_API_KEY 可以在 Credentials 页面上找到:

这里有一些帮助可以通过凭据页面找到您的 api key :

  1. https://console.developers.google.com/project?authuser=0
  2. 单击您想要的项目(如果您有多个项目)
  3. 点击API & auth(如果尚未展开)
  4. 点击 Credentials(在 API & auth 下方)
  5. 然后您将在此屏幕上找到您的 API key

关于android - 获取通知 key 错误 401 gcm https ://android. googleapis.com/gcm/googlenotification,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28835292/

相关文章:

ios - Azure 通知中心不适用于 ios

android - 如何从上下文中获取应用程序

android - GCM (Google Cloud Messaging) 无法覆盖所有注册用户?

android - 需要密码才能运行某些应用程序?

c# - WP7 推送通知服务器设置

android - Glide Images的DiskCache加解密?

c# - 单点触控 : getting NSDictionary value

java - GCM CCS 服务器实现未接收上游消息

android - 解析 C :\Documents and Settings\<user>\. android\devices.xml 时出错

android - 将微调器/进度条添加到 TextView 中?