Chrome扩展程序:获取用户的电子邮件地址登录到Google帐户/ Gmail帐户 [英] chrome extension: getting user's email address who logs into the google account/gmail account
问题描述
我已经构建了一个Chrome扩展。使用chrome.identity.getAuth(),我可以获得此处所述的令牌 https://developer.chrome的.com /应用/ app_identity 。此令牌似乎适用于与Chrome相关联的用户。
我想获取登录到Google帐户/ Gmail帐户的令牌或用户的电子邮件地址。是否有可能从一个扩展中得到这个?
在Google控制台上生成客户端ID时,我可以通过选择Web应用程序类型而不是Chrome应用程序来解决此问题。
-
在google上生成客户端密钥时选择一个web应用程序
Javascript来源:
https://< extensionid> .chromiumapp.org
重定向网址https://< extensionid> .chromiumapp.org / provider_cb
-
通过阅读contentcript中的html来提取电子邮件页面。
传递一封包含此电子邮件地址的消息到后台页面。 按照与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.
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
extract the email page by reading the html from the contentscript.
Pass a message with this email address to the background page.
Follow the same as described in the github launchWebAuthFlow. [https://github.com/GoogleChrome/chrome-app-samples/tree/master/samples/github-auth]
- When calling the google auth url, also pass
login_hint
with the email address.
这篇关于Chrome扩展程序:获取用户的电子邮件地址登录到Google帐户/ Gmail帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!