应用服务器如何将 Google 帐户与用户的设备相关联? [英] How can an application server associate Google accounts to a user's device?

查看:28
本文介绍了应用服务器如何将 Google 帐户与用户的设备相关联?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望用户能够从网络服务器和/或本机 PC 应用程序输入数据,并将其传输到他们选择的 Android 设备,其方式与 Google Play 在设备上的安装方式大致相同.

I want users to be able to enter data from a web server and/or native PC app and transfer it to their chosen Android device in much the same way that Google Play's install on device works.

我想用用户的谷歌账号身份验证在应用服务器之间建立链接以及用户在 GCM 中注册的 Android 设备.

I'd like to use the user's Google account authentication to establish a link between the application server and the user's Android device that registered with GCM.

我在 Google Cloud 消息传递中找不到任何关于如何处理此类身份验证的内容API 文档,但确实发现了这个未回答的问题 在 GCM 论坛中.

I couldn't find any mention of how to handle this kind of authentication in the Google Cloud messaging API documentation, but did find this unanswered question in the GCM forums.

我想通过用户的 Google 帐户对来自网络应用程序的用户进行身份验证.同样,Android 应用程序会以某种方式获得同一个 Google 帐户的句柄,该句柄将在初始 GCM 注册的同时发送到 Web 应用程序服务器.

I'd like to authenticate users from a web application via the his or her Google account. Similarly, the Android application would somehow obtain a handle on the same Google Account, which would be sent to the web application server once at same time as initial GCM registration.

然后当用户使用 Web 应用程序时,服务器会提供用户已经注册到服务器的设备列表,以便可以提示用户他或她想要向哪个 Android 设备发送数据.

Then when the user uses the web application, the server provides a list of devices the user has already registered to the server, so that the user can be prompted about which Android device he or she would like to send data to.

如何在 Web 服务器和设备上完成此操作?

How can I accomplish this on the web server as well as on the device?

通过谷歌账户验证后,我可以使用哪些信息在两次登录之间建立链接?

What information can I use after authenticating with the Google account to establish a link between the two logins?

推荐答案

您应该使用 <之后从 Google 帐户服务器返回的代码>user_id注册以唯一标识每个用户.出于多种原因,不应使用电子邮件地址:

You should use the user_id that is returned from the Google account server after registration to uniquely identify each user. Email addresses shouldn't be used for a number of reasons:

  • 访问电子邮件地址可能需要用户的额外权限,并因信任问题而劝阻用户不要使用您的服务/应用.
  • 增加保护用户电子邮件地址数据库的责任
  • 用户可以更改他们在 Google 帐户中的电子邮件地址,但不能更改他们的用户 ID.
  • 用户可以将一个电子邮件地址与多个用户 ID 相关联,因此它不一定是唯一的.

以下序列图显示了从客户端 Android 应用程序的初始注册:

The following sequence diagram shows the initial registration from client Android app:

下图显示了当客户想要从浏览器访问他的设备时会发生什么:

The next diagram shows what happens when a client wants to access his device from a browser:

请注意,虽然未显示,但客户端 Android 应用现在可以在需要时通过应用服务器与客户端浏览器通信.

Note that although not shown, the client Android app can now communicate back to the client browser if needed via the application server.

这篇关于应用服务器如何将 Google 帐户与用户的设备相关联?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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