com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden

后端 未结 7 1629
隐瞒了意图╮
隐瞒了意图╮ 2020-12-14 23:45

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:

相关标签:
7条回答
  • 2020-12-15 00:11

    I just had this problem and it is likely that you have created the credential file using a scope that does not allow inserting a file. Remove the credential file and re-run.

    0 讨论(0)
  • 2020-12-15 00:14

    I had the same issue, I did the following change and it resolved the issue

    1) Added SheetsScopes.DRIVE to the scopes to be given in authorize()

    private static final List<String> SCOPES =
                Arrays.asList(SheetsScopes.SPREADSHEETS,SheetsScopes.DRIVE);
    

    2) Created a new directory, so that next time I run it, it will authenticate and save the credential to the newly created directory

    private static final java.io.File DATA_STORE_DIR = new java.io.File(
            System.getProperty("user.home"), ".credentials/2/sheets.googleapis.com-java-quickstart.json");
    
    0 讨论(0)
  • 2020-12-15 00:15

    Been having same quota errors for months. Tried everything. It looks like problem on Google side. Among all google products, Calendar API does not have any way to support their team. If anyone knows or have been able to contact Google team about Calendar API, let us know!

    0 讨论(0)
  • 2020-12-15 00:16

    This issue happened when you change SCOPE and proceed to work with the old token. Just remove StoredCredential file.Idea

    0 讨论(0)
  • 2020-12-15 00:31

    After a long time searching, I found this answer hidden in the search engine:

    Change the line where you define scopes to:

    private static final List<String> SCOPES = Arrays.asList(GmailScopes.MAIL_GOOGLE_COM);
    

    https://stackoverflow.com/a/38599382/1317559

    0 讨论(0)
  • 2020-12-15 00:35

    I had the same problem but in my case resolve this with:

    private static final List<String> SCOPES =
            Arrays.asList(DriveScopes.DRIVE);
    

    from DriveScopes

    and also create a new directory

    private static final java.io.File DATA_STORE_DIR = new java.io.File(System.getProperty("user.home"), ".credentials/2/drive-java-quickstart.json");
    

    and i solved the problem

    0 讨论(0)
提交回复
热议问题