Flutter: Google Drive: File list always returns me 0

前端 未结 1 418
无人及你
无人及你 2021-01-27 02:34

I want to retrieve list of files from a Google drive folder. Authentication happens through Service account. Here is my code to do the same:

final _credentials =         


        
相关标签:
1条回答
  • 2021-01-27 03:29

    Retrieving files using Service account:

    The service account is different from your Google account. This means that the Google Drive is also different between Service account and your account. So when the file is retrieved using Service account, please share the files in your Google Drive with the Service account. By this, the files in your Google Drive can be retrieved by the Service account.

    Scopes:

    In your script, DriveFileScope and SpreadsheetsScope are used as the scopes. DriveFileScope is https://www.googleapis.com/auth/drive.file. The official document says this scope as follows.

    View and manage Google Drive files and folders that you have opened or created with this app

    By this, in your script, how about modifying DriveFileScope as follows?

    • DriveReadonlyScope (https://www.googleapis.com/auth/drive.readonly)
    • DriveScope (https://www.googleapis.com/auth/drive)

    Note:

    • I think that this scope can be also used for your situation.
      • DriveApi.driveMetadataReadOnlyScope (https://www.googleapis.com/auth/drive.metadata.readonly)

    References:

    • Scopes for Google Sheets API, v4
    • Scopes for Drive API, v3
    0 讨论(0)
提交回复
热议问题