Chrome中的XMLHttpRequest锁定浏览器 [英] XMLHttpRequest in Chrome locks up browser
问题描述
我有下面的代码(我不建议运行它):
let req = new XMLHttpRequest();
req.open('GET','https://www.googleapis.com/oauth2/v1/userinfo?alt=json&access_token='+ token);
req.onload = function(){
console.log('response:',req.response);
};
req.send();
会发生什么情况会打开一个新标签,并且此标签完全窃取所有焦点。我无法使用任何其他Chrome标签,它会迅速切换回授权标签。如果我使用auth选项卡登录,它只是重新加载相同的auth选项卡,然后我又回到原来的位置。
令牌通过此调用获取:
chrome.identity.getAuthToken({interactive:true},function(token){}):
code>
有没有人看到这个可怕的问题?我无法让Chrome停止向截图中的网址发送身份验证请求。它一直在窃取焦点,并迫使我一遍又一遍地登录。
从我所知道的情况来看,这实际上是这次调用给我带来的黑洞认证tab:
chrome.identity.getAuthToken()
这并没有用于发生,但似乎在我将它添加到我的manifest.json文件后开始发生:
< pre $
oauth2:{
client_id:5461xxx462-7gebv033e9csxxxxg5f6ggu22rju9374.apps.googleusercontent.com,
scopes:[
https://www.googleapis.com/oauth2/v1/userinfo,//添加了这一行
https://www.googleapis.com/oauth2/v1/userinfo.picture,//并添加了此行
https://www.googleapis.com/auth/chromewebstore.readonly
},
旧的登录屏幕看起来像这样,并且这非常好用:
p>
https://www.googleapis.com/oauth2/v1/userinfo
https:// www。 googleapis.com/oauth2/v1/userinfo.picture
我该怎么做?
之前我曾遇到过这个问题,但它是几个月前的事。如果我没有记错,那么client_id是无效的。仔细检查你的oauth client_id,确保你使用的是正确的。
I have the following code (I don't recommend running it):
let req = new XMLHttpRequest();
req.open('GET', 'https://www.googleapis.com/oauth2/v1/userinfo?alt=json&access_token=' + token);
req.onload = function() {
console.log('response:', req.response);
};
req.send();
What happens is this opens up a new tab, and this tab completely steals all the focus. I can't use any of the other Chrome tabs, it quickly switches back to the auth tab. And if I log-in with the auth tab, it just reloads the same auth tab, and I am back to square one.
The token is acquired via this call:
chrome.identity.getAuthToken({interactive: true}, function (token) {}):
Has anyone seen this horrible problem? I can't get Chrome to stop making an auth request to the url in the screenshot. It keeps stealing the focus, and forcing me to login over and over again.
From what I can tell, it's actually this call this brings to me to the black hole authentication tab:
chrome.identity.getAuthToken()
This didn't use to happen, but seems like it started happening after I added this to my manifest.json file:
"oauth2": {
"client_id": "5461xxx462-7gebv033e9csxxxxg5f6ggu22rju9374.apps.googleusercontent.com",
"scopes": [
"https://www.googleapis.com/oauth2/v1/userinfo", // added this line
"https://www.googleapis.com/oauth2/v1/userinfo.picture", // and added this line
"https://www.googleapis.com/auth/chromewebstore.readonly"
]
},
The old login screen looks like this, and this worked really nicely:
I am currently fairly certain that these two lines in the scopes array are what are causing the problem:
"https://www.googleapis.com/oauth2/v1/userinfo"
"https://www.googleapis.com/oauth2/v1/userinfo.picture"
what do I do?
I've had this problem before but it was months ago. If I recall correctly, it ended up being that the client_id was invalid. Double check your oauth client_id to make sure you're using the correct one.
这篇关于Chrome中的XMLHttpRequest锁定浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!