Gmail API“错误403:请求的身份验证范围不足"使用Go语言 [英] Gmail API "Error 403: Request had insufficient authentication scopes" with Go language

查看:88
本文介绍了Gmail API“错误403:请求的身份验证范围不足"使用Go语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

按照Go快速入门说明此处,启用Gmail API,下载客户端配置,然后执行quickstart.go.以下行显示了正在请求GmailSendScope.

Following the Go Quickstart instructions here , enabled the Gmail API, downloaded the client configuration and then executed quickstart.go. The following line shows the GmailSendScope is being requested.

config, err := google.ConfigFromJSON(b, gmail.GmailSendScope)

按照其余说明进行操作.保存token.json时,程序显示以下消息:

Followed the rest of the instructions. While saving the token.json, the program displayed following message:

Saving credential file to: token.json
2020/10/07 12:36:13 Unable to retrieve labels: googleapi: Error 403: Request had 
insufficient authentication scopes.
More details:
Reason: insufficientPermissions, Message: Insufficient Permission

在开发人员控制台上,我确实看到类型为Quickstart项目的Desktop的Oauth客户端,并且安全屏幕确实显示我允许应用程序使用我的gmail帐户发送电子邮件.

On the developer console, I do see Oauth client of type Desktop for Quickstart project and the security screen did show that I am allowing application to send emails using my gmail account.

我不确定如何解决此问题.

I am not sure how to fix this issue.

macOS Catalina 10.15.7,go1.15.2 darwin/amd64

macOS Catalina 10.15.7, go1.15.2 darwin/amd64

感谢帮助!

推荐答案

感谢Tanaike.使用gmail.MailGoogleComScope解决了该问题!

Thanks to Tanaike. Using gmail.MailGoogleComScope solved the issue!

这篇关于Gmail API“错误403:请求的身份验证范围不足"使用Go语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆