【发布时间】:2019-08-03 09:34:08
【问题描述】:
我正在尝试使用 Gmail API javascript 代码访问其他电子邮件,代码如下:-
function authenticate() {
return gapi.auth2.getAuthInstance()
.signIn({ scope: "https://mail.google.com/ https://www.googleapis.com/auth/gmail.compose https://www.googleapis.com/auth/gmail.modify https://www.googleapis.com/auth/gmail.readonly" })
.then(function () { console.log("Sign-in successful"); },
function (err) { console.error("Error signing in", err); });
}
function loadClient() {
return gapi.client.load("https://content.googleapis.com/discovery/v1/apis/gmail/v1/rest")
.then(function () { console.log("GAPI client loaded for API"); },
function (err) { console.error("Error loading GAPI client for API", err); });
}
// Make sure the client is loaded and sign-in is complete before calling this method.
function execute() {
return gapi.client.gmail.users.getProfile({})
.then(function (response) {
// Handle the results here (response.result has the parsed body).
console.log("Response", response);
},
function (err) { console.error("Execute error", err); });
}
gapi.load("client:auth2", function () {
gapi.auth2.init({ client_id: "681860637449-ar2gfuhr23nf88h2ct7b5fs0oh213a0n.apps.googleusercontent.com" });
});
当我尝试访问其他电子邮件时,我遇到了关于 此应用未验证的问题,这里是
的屏幕截图
1. 同意屏幕(已发布 URL)
2. Gmail 登录(从 javascript 代码登录)
3. 应用未验证
【问题讨论】:
-
您是否检查过 DaImTo 提供的关于如何验证应用程序的 Gmail API Google OAuth 的 SO post 解决方案?从 2017 年 7 月 18 日开始,请求某些敏感 OAuth 范围的 Google OAuth 客户端将接受 Google 的审核。这里还有一份关于Unverified Apps 的支持文档。
-
但它仍然无济于事,因为同意屏幕不接受本地主机。我已经搜索了整个堆栈,但网络仍然找不到解决方案,因为没有准确的解决方案来测试本地主机 gmail api。
-
那么@namco 你解决了这个问题吗?
-
@nullwriter 尚未解决 .. 发现您需要购买一些东西才能购买某种商务套件。
标签: javascript gmail gmail-api