Google GCM,令牌与注册ID [英] Google GCM, token vs registration id
问题描述
我对注册ID和代币之间的关系感到困惑。在Google的GCM教程中,我们在开始时注册注册ID。但是,我们也得到了一个令牌。现在,在图中,我们将注册ID发送到目标服务器。但是,我们是否也发送令牌?我知道该令牌是从注册ID派生的。该令牌是否被用作GCM与应用程序之间的认证机制,而服务器永远不会知道该令牌?
如果您正在寻找有关Google Cloud Messaging,IMO的基本知识,请参阅以下内容:
基本上,您需要执行以下步骤:
- 在 Google Developers Console 。在这个
的步骤中,为了简单起见,您只需要注意2个值:项目编号
,其中
将会在客户端项目中用作SENDER_ID
;和API服务器密钥
(在 Credentials 处创建),其中
将在服务器项目中作为API_KEY
使用。 - 为服务器端创建一个新的简单Android项目(使用基本源代码作为我的答案在下面的链接中)。
- 为客户端创建一个新的简单Android项目(使用基本源代码作为我在下面的链接中的答案,我从原始源定制 Google Cloud Messaging - GitHub )。
- 运行客户端应用程序,您将获得注册令牌(意味着您的设备已成功注册)。然后,将该令牌粘贴(硬编码)在服务器应用程序的
CLIENT_REGISTRATION_TOKEN
变量中(或编写代码将此令牌发送到服务器应用程序)。
您可以在以下问题中阅读更多内容,其中一个您之前曾阅读过以前的问题之一:
欲了解更多信息: Google Cloud Messaging:Overview
$ b
凭证
- 发件人ID 配置您的API项目时创建的唯一数值在Google Developers Console中以项目编号的形式给出)。在注册过程中使用发件人ID来标识允许向客户端应用发送消息的应用服务器。
该应用服务器为应用服务器授权访问Google服务。在HTTP中,API密钥是
,包含在发送消息的POST请求头中。在XMPP中,
API密钥在SASL PLAIN身份验证请求中用作
密码来验证连接。当
配置您的API项目时,您将获得API密钥。
- 注册令牌由GCM连接服务器向客户端应用程序发出的ID,允许它接收消息。请注意,
注册令牌必须保密。
希望这有助于您! p>
I am confused on relationship between registration id and tokens. In the tutorial for GCM from Google, we register for a registration id in the beginning. However, we also get a token. Now, in the diagrams, we send the registration id to the targeted server. However, do we also send the token? I know that the token is derived from the registration id. Is the token used as an authentication mechanism between GCM and the app and the server never knows about the token?
If you are looking for a basic knowledge about Google Cloud Messaging, IMO, you can refer to the following:
Basically, you need to do the steps:
- Create a new project at Google Developers Console . At this
step, for simplicity, you just need to take note of 2 values:
Project Number
, which will be used asSENDER_ID
in the client project; andAPI server key
(created at Credentials), which will be used asAPI_KEY
in the server project. - Create a new simple Android project for server side (with basic source code as my answer in the following links).
- Create a new simple Android project for client side (with basic source code as my answer in the following links, I customized from the original source at Google Cloud Messaging - GitHub).
- Run the client app, you will get the registration token (means that your device has successfully registered). Then, paste (hard-code) this token at
CLIENT_REGISTRATION_TOKEN
variable in server app (or write code to send this token to server app).
You can read more at the following questions, one of them you have read before with one of your previous questions:
- How to implement a GCM Hello World for Android using Android Studio
- Adding Google Cloud Messagin (GCM) for Android - Registration process
For more information:
Key Concepts from Google Cloud Messaging: Overview
Credentials
- Sender ID A unique numerical value created when you configure your API project (given as "Project Number" in the Google Developers Console). The sender ID is used in the registration process to identify an app server that is permitted to send messages to the client app.
- API Key An API key saved on the app server that gives the app server authorized access to Google services. In HTTP, the API key is included in the header of POST requests that send messages. In XMPP, the API key is used in the SASL PLAIN authentication request as a password to authenticate the connection. You obtain the API key when you configure your API project.
- Registration Token An ID issued by the GCM connection servers to the client app that allows it to receive messages. Note that registration tokens must be kept secret.
Hope this helps!
这篇关于Google GCM,令牌与注册ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!