问题描述
我正在编写一个请求对Google云端硬盘具有读写访问权限的应用程序,并且该应用程序仅限于我的应用程序创建的文件夹。我正在使用以下范围:
"https://www.googleapis.com/auth/drive.file","https://www.googleapis.com/auth/userinfo.email"
我发现,间歇性地(可能是30%的时间),当用户尝试在Google云端硬盘中创建文件夹时,我收到403错误:Error 403: Insufficient Permission: Request had insufficient authentication scopes.
为什么会这样?用户是否可以成功完成OAuth流程,但无法授予所请求的范围?当我使用个人帐户进行测试时,我什至没有看到在拒绝这些范围的情况下继续登录的选项。
就我而言,这是我在Go中失败的相关代码段:
import "google.golang.org/api/drive/v3"
srv,_ := drive.New(client) // client is of type *http.Client
newFile := &drive.File{
Name: "My Folder Name",MimeType: "application/vnd.google-apps.folder",Parents: []string{"root"},}
file,err := srv.Files.Create(newFile).Fields("webViewLink","id").Do()
if err != nil {
log.Println("Could not create google folder:",err.Error())
return err
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)