Chrome扩展程序:获取用户的电子邮件地址登录到Google帐户/ Gmail帐户 [英] chrome extension: getting user's email address who logs into the google account/gmail account

查看:147
本文介绍了Chrome扩展程序:获取用户的电子邮件地址登录到Google帐户/ Gmail帐户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经构建了一个Chrome扩展。使用chrome.identity.getAuth(),我可以获得此处所述的令牌 https://developer.chrome的.com /应用/ app_identity 。此令牌似乎适用于与Chrome相关联的用户。



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

解决方案

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


  1. 在google上生成客户端密钥时选择一个web应用程序

    Javascript来源 https://< extensionid> .chromiumapp.org



    重定向网址 https://< extensionid> .chromiumapp.org / provider_cb


  2. 通过阅读contentcript中的html来提取电子邮件页面。

  3. 传递一封包含此电子邮件地址的消息到后台页面。 按照与github launchWebAuthFlow中所述的相同的方式。 [ https://github.com/GoogleChrome/chrome在调用google auth网址时,还需要传递 login_hint 与电子邮件地址。


I have built a chrome extension. Using chrome.identity.getAuth(), I am able to get token as described here https://developer.chrome.com/apps/app_identity. This token seems to be for the user who is associated with the chrome.

I want to get a token or a user's email address who logs into the google account/gmail account. Is it possible to get this from within an extension?

解决方案

I was able to solve this by choosing a web application type instead of a chrome app when generating the client id on google console.

  1. Choose a web application when you are generating the client key on google

    Javascript origins: https://<extensionid>.chromiumapp.org

    redirect url https://<extensionid>.chromiumapp.org/provider_cb

  2. extract the email page by reading the html from the contentscript.

  3. Pass a message with this email address to the background page.

  4. Follow the same as described in the github launchWebAuthFlow. [https://github.com/GoogleChrome/chrome-app-samples/tree/master/samples/github-auth]

  5. When calling the google auth url, also pass login_hint with the email address.

这篇关于Chrome扩展程序:获取用户的电子邮件地址登录到Google帐户/ Gmail帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆