【问题标题】:google plus authentication for web谷歌加网络身份验证
【发布时间】:2014-06-03 07:53:36
【问题描述】:

我希望我的网络应用程序使用 google plus 身份验证,当用户通过 google plus 身份验证登录时,它会返回用户的电子邮件。

我为此做了以下代码,它成功登录但它没有返回电子邮件。

<span id="signinButton">
 <span
  class="g-signin"
  data-callback="signinCallback"
  data-clientid="CLIENT_ID"
  data-cookiepolicy="single_host_origin"
  data-requestvisibleactions="http://schemas.google.com/AddActivity"
  data-scope="https://www.googleapis.com/auth/plus.login email">
 </span>
</span> 

JSON 的结果是:

{
  "state": "",
  "access_token": "***",
  "token_type": "Bearer",
  "expires_in": "3600",
  "code": "***",
  "scope": "https:\/\/www.googleapis.com\/auth\/plus.login https:\/\/www.googleapis.com\/auth\/userinfo.email",
  "id_token": "*****",
  "authuser": "0",
  "num_sessions": "1",
  "session_state": "***",
  "prompt": "none",
  "client_id": "*******",
  "g_user_cookie_policy": "single_host_origin",
  "cookie_policy": "single_host_origin",
  "response_type": "***",
  "issued_at": "140182",
  "expires_at": "1014176",
  "g-oauth-window": {

  },
  "status": {
    "google_logged_in": true,
    "signed_in": true,
    "method": "PROMPT"
  }
}

我应该怎么做才能收到电子邮件?

【问题讨论】:

    标签: javascript json google-plus


    【解决方案1】:

    您需要将您的data-scope 更改为:

    data-scope="https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/plus.profile.emails.read"
    

    阅读更多: https://developers.google.com/+/web/people/#retrieve_an_authenticated_users_email_address

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-09-20
      • 2020-08-15
      • 2018-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-20
      相关资源
      最近更新 更多