Google Drive Service Account - view files from another account

后端 未结 3 1231
忘掉有多难
忘掉有多难 2021-01-07 22:34

I have successfully created a Google Drive Service Account and can create files via PHP to this account. However I need to be able to view these created files from the Googl

相关标签:
3条回答
  • 2021-01-07 23:08

    Jay is spot on. Check out API v3 permission guide and reference. My other advice would be to first create a folder and set its permissions which are then inherited by any child files, e.g. in Python (sorry, don't know PHP!):

        # Folder setup
        folder_metadata = {
            'name': 'Searchable folder name',
            'mimeType': 'application/vnd.google-apps.folder'
        }
        folder = drive_service.files().create(
            body=folder_metadata,
        ).execute()
    
        domain_permission = {
            'type': 'domain',
            'role': 'reader',
            'domain': 'example.com',
            'allowFileDiscovery': True,  # so they show up in user searches
        }
        drive_service.permissions().create(
            fileId=folder['id'],
            body=domain_permission,
        ).execute()
    
        # New files
        body = {
            'name': 'Searchable filename',
            'parents': [folder['id']],
        }
        drive_service.files().create(
            media_body=...,
            body=body,
        ).execute()
    
    0 讨论(0)
  • 2021-01-07 23:16

    One option is to Perform Google Apps Domain-Wide Delegation of Authority: https://developers.google.com/drive/web/delegation

    0 讨论(0)
  • 2021-01-07 23:17

    You just need to share the file with the desired users with:

    https://developers.google.com/drive/v2/reference/permissions/insert

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