【发布时间】:2019-06-15 21:42:28
【问题描述】:
我正在尝试建立一个用户可以通过 google 登录注册的系统,我需要一个始终不变的用户详细信息。我认为那是 ID,但这几乎是我无法通过 PHP 获得的唯一细节。
我可以使用令牌 ID 获取有关用户的详细信息,它会返回此信息。
"iss": "https://accounts.google.com",
"sub": "110169484474386276334",
"azp": "1008719970978-hb24n2dstb40o45d4feuo2ukqmcc6381.apps.googleusercontent.com",
"aud": "1008719970978-hb24n2dstb40o45d4feuo2ukqmcc6381.apps.googleusercontent.com",
"iat": "1433978353",
"exp": "1433981953",
// These seven fields are only included when the user has granted the "profile" and
// "email" OAuth scopes to the application.
"email": "testuser@gmail.com",
"email_verified": "true",
"name" : "Test User",
"picture": "https://lh4.googleusercontent.com/-kYgzyAWpZzJ/ABCDEFGHI/AAAJKLMNOP/tIXL9Ir44LE/s99-c/photo.jpg",
"given_name": "Test",
"family_name": "User",
"locale": "en"
但我找不到唯一且不变的详细信息,因此我可以查看他们的帐户是否已经存在。还有什么我可以使用的或者我可以通过 php 检索用户的 ID 吗?
【问题讨论】:
-
Google 帐户的电子邮件必须是唯一的;-)
标签: php oauth-2.0 google-signin