gpt4 book ai didi

google-chrome-extension - 运行 chrome 扩展的 identity.getAuthToken 时出现错误 'Service has been disabled for this account'

转载 作者:行者123 更新时间:2023-12-03 23:54:19 25 4
gpt4 key购买 nike

我正在尝试创建一个使用所选数据并将其保存到 Google 表格的扩展程序。虽然听起来很简单,但我被困在 Auth2 部分。

这是我到目前为止所做的:

我创建了一个 manifest.json并将其上传到 chrome 开发者仪表板以获取“key”和“id”。

使用“id”获取身份验证客户端 ID 并将其添加到我的 manifest.json .

接下来,我在“popup.html”中添加了基本 html,在“options.js”中添加了上下文菜单代码部分,它被定义为“manifest.json”中的背景脚本。

接下来我使用“getAuthToken”来获取“popup.js”中的 token 。当我运行扩展程序时,一切正常,但是一旦我单击按钮获取 token ,就什么也没有发生,并且返回“未定义” token 值。错误消息是

Unchecked runtime.lastError while running identity.getAuthToken: OAuth2 request failed: Service responded with error: 'Service has been disabled for this account.'



list 文件
{
"name":"ext1",
"manifest_version":2,
"version": "1.0",
"description":"",
"browser_action":{
"default_icon":"icon48.png",
"default_popup":"popup.html"
},

"permissions":[
"identity",
"https://*/*",
"http://*/*",
"contextMenus",
"https://accounts.google.com/o/oauth2/token",
"storage"
],
"background":{
"scripts":["options.js"],
"persistent":false
},
"content_security_policy":"script-src 'self' https://apis.google.com; object-src 'self'",
"oauth2":{
"client_id":"<>.apps.googleusercontent.com",
"scopes":[
"https://www.googleapis.com/auth/spreadsheets"
]
},
"key":"<>"}

弹窗.html
 <!doctype <!DOCTYPE html>
<html>
<head>
<title>text</title>
<script src="jquery-3.3.1.min.js"></script>
<script src="popup.js"></script>

</head>

<body>
<h1>random text</h1>
<h2> Data: <span id="data"></span></h2>
<input type="submit" id="button" value="Authorize">
</body>
</html>

弹出窗口.js
$(function(){
chrome.storage.sync.get('datas', function(values){
$('#data').text(values.datas);
})
$("#button").on("click",function(){
chrome.identity.getAuthToken({"interactive":true},function(token){
alert("getting token......")
console.log("token")
console.log(token);
})
})
})

我试过寻找类似的问题,但没有一个能解决我的问题。请帮助我做错了什么。

最佳答案

您可能正在使用 Google 帐户 advanced protection禁用非 Google 应用程序的 Gmail 和 Google Drive 相关 API 访问:

To keep your data secure, most non-Google apps and services won’t be able to access some data in your Google Account, like Google Drive or Gmail. *


另请参阅 Google 的此公告: https://cloud.google.com/blog/products/identity-security/enhancing-security-controls-for-google-drive-third-party-apps

Today we’re announcing plans to extend the same policy to Google Drive as part of Project Strobe.


With this updated policy, we’ll limit the types of apps that have broad access to content or data via Drive APIs.

关于google-chrome-extension - 运行 chrome 扩展的 identity.getAuthToken 时出现错误 'Service has been disabled for this account',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51578410/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com