【问题标题】:How to explicitly request dialog to show up when getting auth token in chrome extension?在 chrome 扩展中获取身份验证令牌时如何显式请求显示对话框?
【发布时间】:2018-02-15 04:57:28
【问题描述】:

我正在为 gmail 制作 Chrome 扩展程序,当我第一次运行这个 sn-p 代码时,一切都很好,对话框出现并询问用户要使用哪个帐户并存储令牌,我可以使用我的扩展程序中的 gmail API:

var access_token = "";
chrome.identity.getAuthToken({ 'interactive': true },
        function(token) {
            if (!!token) {
                access_token = token;
                gapi.auth.setToken({ access_token: token });                 
            }
        }
    );

但是当我用这段代码的 sn-p 删除令牌时:

chrome.identity.removeCachedAuthToken({ token: access_token }, function() {
            console.log('token removed');                
        });

我想使用第一个 sn-p 再次获取令牌,它会更新令牌本身,而不向用户显示对话框以选择要使用的帐户。 如何强制它显示对话框?

【问题讨论】:

标签: google-chrome google-chrome-extension oauth google-oauth gmail-api


【解决方案1】:

正如 cmets 中所确认的,您需要 revoke the token 才能完全删除存储的凭据。

   curl -H "Content-type:application/x-www-form-urlencoded" \
        https://accounts.google.com/o/oauth2/revoke?token={token} 

【讨论】:

    猜你喜欢
    • 2012-01-08
    • 1970-01-01
    • 1970-01-01
    • 2019-03-05
    • 1970-01-01
    • 1970-01-01
    • 2019-01-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多