Google chrome extension 检索Gmail访问令牌
我需要找到用户登录GMail后发送到浏览器的googleaccess\u令牌。它应该在cookies中的某个地方,或者在浏览器本地存储中 问题是Google chrome extension 检索Gmail访问令牌,google-chrome-extension,gmail,google-oauth,gmail-api,Google Chrome Extension,Gmail,Google Oauth,Gmail Api,我需要找到用户登录GMail后发送到浏览器的googleaccess\u令牌。它应该在cookies中的某个地方,或者在浏览器本地存储中 问题是 chrome.identity.launchWebAuthFlow({url:authURL,interactive:true},cb) 希望用户再次选择帐户,即使他已经登录到GMail 我真正想要的是类似于Microsoft OutlookOffice.context.mailbox.getCallbackTokenAsync的东西,它允许登录用户使
chrome.identity.launchWebAuthFlow({url:authURL,interactive:true},cb)
希望用户再次选择帐户,即使他已经登录到GMail
我真正想要的是类似于Microsoft OutlookOffice.context.mailbox.getCallbackTokenAsync
的东西,它允许登录用户使用Microsoft REST API而无需再次验证
p.S.GMail允许用户同时登录到多个google帐户,其中每个浏览器选项卡可能显示不同的活动邮箱
p.p.S.这似乎是一个可以在谷歌上搜索到的众所周知的问题:
我在开发人员控制台中找不到GX cookie,可能它不再相关了。取而代之的是最像“指南针”的cookie,它属于google域,安全且仅限于http 我尝试在gmail上下文中运行此代码,但仍然失败:
let actualCode = '(' + function() {
let access_token = '[COMPASS cookie]';
window.fetch('https://www.googleapis.com/oauth2/v1/userinfo?alt=json', {
credentials: "include"
}).then(res => {
return res.text().then(dt => ({text: dt, status: res.status}));
}).then(res => {
console.log(res);
});
window.fetch('https://www.googleapis.com/oauth2/v1/userinfo?alt=json&access_token=' + access_token, {
}).then(res => {
return res.text().then(dt => ({text: dt, status: res.status}));
}).then(res => {
console.log(res);
});
} + ')();';
let script = document.createElement('script');
script.textContent = actualCode;
(document.head||document.documentElement).appendChild(script);
在这两种情况下,我都会得到
401:无效的凭据。按照此快速入门中的步骤进行操作,我想您将获得一个您正在寻找的示例 -无法在Chrome扩展中使用GAPI。这是已知问题。这可能有用吗?否则我就完全错过了目标。调用getAuthToken时,可以传递一个标志('interactive':false)->静默模式。这就是问题所在。为了使用{'interactive':false},我需要用这个脚本登录。它无法识别已经登录到GMail的用户。