com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden(com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden)
问题描述
我正在尝试将文本文件上传到我的 Google 云端硬盘帐户.无论如何,我总是遇到 com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
I am trying to upload a text file to my Google Drive account. No matter what, I always encounter an com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
这是 DriveCommandLine.java
完整代码:
我的项目构建路径中有以下 jar:
I have the following jars in my project build path:
目前我有两个启用 Drive API 的项目.
At present I have two projects set up with Drive API enabled.
现在我应该在哪里正确设置权限来解决这个问题?
Now where do I properly set up the permissions to resolve this issue?
另外,我在这里做错了什么?
Also, what am I doing wrong here?
推荐答案
我遇到了同样的问题,我做了以下更改并解决了问题
I had the same issue, I did the following change and it resolved the issue
1) 将 SheetsScopes.DRIVE 添加到要在 authorize() 中给出的范围
1) Added SheetsScopes.DRIVE to the scopes to be given in authorize()
2) 创建了一个新目录,这样下次我运行它时,它会进行身份验证并将凭据保存到新创建的目录中
2) Created a new directory, so that next time I run it, it will authenticate and save the credential to the newly created directory
这篇关于com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!