简体   繁体   English

应用服务器如何将Google帐户与用户的设备相关联?

[英]How can an application server associate Google accounts to a user's device?

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. 我希望用户能够从Web服务器和/或原生PC应用程序输入数据并将其传输到他们选择的Android设备,就像Google Play在设备上安装的方式一样。

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帐户身份验证在应用服务器和向GCM注册的用户的Android设备之间建立链接。

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云端消息传递API文档中找不到如何处理此类身份验证,但确实在GCM论坛中找到了这个未解决的问题

I'd like to authenticate users from a web application via the his or her Google account. 我想通过他或她的Google帐户通过网络应用程序对用户进行身份验证。 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. 同样,Android应用程序会以某种方式获取同一Google帐户的句柄,该帐户将在初始GCM注册的同时发送到Web应用程序服务器。

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应用程序时,服务器提供用户已经注册到服务器的设备列表,以便可以提示用户他或她想要将数据发送到哪个Android设备。

How can I accomplish this on the web server as well as on the device? 如何在Web服务器和设备上完成此操作?

What information can I use after authenticating with the Google account to establish a link between the two logins? 在使用Google帐户进行身份验证后,我可以使用哪些信息在两次登录之间建立链接?

You should use the user_id that is returned from the Google account server after registration to uniquely identify each user. 您应该使用注册后从Google帐户服务器返回的user_id来唯一标识每个用户。 Email addresses shouldn't be used for a number of reasons: 不得出于多种原因使用电子邮件地址:

  • Accessing email addresses may require additional permissions from the user and dissuade users from using your service/app because of trust issues. 访问电子邮件地址可能需要用户提供其他权限,并且由于信任问题而阻止用户使用您的服务/应用。
  • Adds liability for securing database of users' email addresses 增加保护用户电子邮件地址数据库的责任
  • Users may change their email addresses in Google accounts but cannot change their user IDs. 用户可以更改Google帐户中的电子邮件地址,但无法更改其用户ID。
  • Users can associate one email address with more than one user ID, so it is not necessarily unique. 用户可以将一个电子邮件地址与多个用户ID相关联,因此它不一定是唯一的。

The following sequence diagram shows the initial registration from client Android app: 以下序列图显示了客户端Android应用程序的初始注册:

从客户端Android应用初始注册

The next diagram shows what happens when a client wants to access his device from a browser: 下图显示了客户端想要从浏览器访问其设备时会发生什么:

客户想要从浏览器访问他的设备

Note that although not shown, the client Android app can now communicate back to the client browser if needed via the application server. 请注意,虽然未显示,但客户端Android应用程序现在可以通过应用程序服务器在需要时与客户端浏览器进行通信。

The user_id you get from the device when you register with GCM should be the same as the user_id you get with your OAuth token for your app. 您在注册GCM时从设备获得的user_id应与您使用应用的OAuth令牌获得的user_id相同。 Just store the OAuth token and Registration ID in your user repository, associating both with the user_id. 只需将OAuth令牌和注册ID存储在用户存储库中,并将其与user_id相关联。

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何直接从Google的GCM服务器中注销用户的设备? - How can I unregister user's device directly from Google's GCM server? 如何将多个Google帐户添加到Android应用中,以便用户可以在多个帐户之间切换 - How to add multiple google accounts to an android app so that user can switch between accounts 如何在Android应用上使用Google+帐户提供多用户访问权限 - How can I provide multiple-user access using Google+ accounts on the Android app 如何解决Google Play上的设备与应用之间的不兼容问题? - How can I Fix incompatibility between device and application on Google Play? 如何将我的用户的消费与他们在 firebase 中的个人资料相关联? - How do I associate my user's spending with their profile in firebase? 将Xamarin GCM设备令牌与登录用户相关联 - Associate Xamarin GCM device token with logged in user 如何将对象与Google Maps标记关联? - How can I associate an object with a Google Maps marker? 如何在项目中使用google api强制在android设备选择器中进行Android自动化设备选择 - how can I force Android Automated device selection in the android device chooser with google api's in a project Android应用程序检查设备上的用户Dropbox帐户 - Android app check for user Dropbox accounts on device 在Device中找不到应用程序的软件包? - Application's package can't find in Device?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM