2014-09-03 98 views
1

我已经构建了一个Chrome扩展。使用chrome.identity.getAuth(),我可以获得这里描述的令牌https://developer.chrome.com/apps/app_identity。该令牌似乎适用于与chrome关联的用户。Chrome扩展程序:获取用户的电子邮件地址登录到Google帐户/ Gmail帐户

我想获取登录到Google帐户/ Gmail帐户的令牌或用户的电子邮件地址。是否有可能从一个扩展中得到这个?

+0

看看这个问题:http://stackoverflow.com/questions/25301018/chrome-app-getting-logged-in-users-email-address – Xan 2014-09-03 21:51:40

+0

所以我可以得到铬用户的电子邮件。但如果我切换Google帐户,我希望收到电子邮件或身份证明。例如:使用不同的登录名登录到谷歌日历。 – ssinganamalla 2014-09-03 22:22:51

+0

认真阅读问题,这不是关于Chrome用户,而是与令牌关联的用户。更具体地说,看看答案。 – Xan 2014-09-03 22:24:37

回答

1

在Google控制台上生成客户端ID时,我可以通过选择Web应用程序类型而不是Chrome应用程序来解决此问题。

  1. 选择当生成对谷歌的客户端密钥

    JavaScript源一个Web应用程序:https://<extensionid>.chromiumapp.org

    重定向URLhttps://<extensionid>.chromiumapp.org/provider_cb

  2. 通过阅读提取电子邮件页面来自内容的html。

  3. 将此电子邮件地址的消息传递到背景页面。

  4. 请按照与github launchWebAuthFlow中所述相同的方式进行操作。 [https://github.com/GoogleChrome/chrome-app-samples/tree/master/samples/github-auth]

  5. 当拨打谷歌身份验证网址时,还通过login_hint与电子邮件地址。
相关问题