[英]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: 不得出于多种原因使用电子邮件地址:
The following sequence diagram shows the initial registration from client Android app: 以下序列图显示了客户端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.