如何成功"生成的客户端和QUOT一个关键的通知;与GCM? [英] How to successfully "Generate a Notification Key on the Client" with GCM?
问题描述
我按照下面的说明,但反应总是HTTP 401未经授权。我已验证了ID令牌,注册ID和项目ID(数字)都是有效的。不幸的是,响应不提供详细的原因。
I'm following the below instructions, but the response is always HTTP 401 Unauthorized. I have verified that the ID token, registration ID, and project ID (number) are all valid. Unfortunately the response does not provide a detailed reason.
https://developer.android.com/google/gcm/ notifications.html#发电机客户
什么是必要的接收与notification_key HTTP 200回应?我想知道,如果文档中缺少一个重要的细节,或如果有一个已知的问题与服务。否则GCM和谷歌身份验证令牌是为我工作的罚款。
What is necessary to receive an HTTP 200 response with the notification_key? I'm wondering if the documentation is missing an important detail or if there is a known issue with the service. Otherwise GCM and the Google auth token are working fine for me.
下面是一个绝密网络日志。是否请求要求未在文件中指定的任何其他标头或JSON字段?
Here is a redacted net log. Does the request require any other headers or JSON fields that are not specified in the documentation?
---> HTTP POST https://android.googleapis.com/gcm/googlenotification
project_id: {project-number}
Content-Type: application/json; charset=UTF-8
{"id_token":"{long-auth-token}",
"notification_key_name":"{unique-name}",
"operation":"add",
"registration_ids":["{reg-id}"]}
<--- HTTP 401 https://android.googleapis.com/gcm/googlenotification
编辑:我怀疑是不是 id_token
字段是不是正在使用的服务。如果我删除任何其他领域,响应 {错误:丢失\\{字段名} \\场}
。但它不会返回时 id_token
缺少一个类似的反应。
I'm suspicious that the id_token
field is not being used by the service. If I remove any other field, the response is {"error":"Missing \"{field-name}\" field"}
. But it doesn't return a similar response when id_token
is missing.
推荐答案
您可以尝试创建一个新的API密钥一个新的项目,看看你仍然得到401错误。并确保您有'允许的任何IP不只是IPv4的0.0.0.0/0。
You can try creating a new project with a new API key and see if you are still getting 401 error. And make sure you have 'Any IP allowed' not just IPv4 0.0.0.0/0.
这篇关于如何成功&QUOT;生成的客户端和QUOT一个关键的通知;与GCM?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!