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

谁说我不能喝 提交于 2019-11-30 23:14:51

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:

  • 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.
  • Users can associate one email address with more than one user ID, so it is not necessarily unique.

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:

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

Paul Fryer

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. Just store the OAuth token and Registration ID in your user repository, associating both with the user_id.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!