【发布时间】:2017-08-29 19:58:38
【问题描述】:
我是 Google Drive API 的新手,我很难在文档和其他帖子中找到答案。我正在编写一个 Ruby 脚本来将文件移入/移出 Google 团队驱动器,并希望能够查看每个文件的最后修改用户的电子邮件地址。我可以在 API Explorer 中运行我的查询并获得我正在寻找的结果,但是当我从我的脚本运行相同的查询时,我只能看到最后修改用户的显示名称和其他几个数据点,但没有电子邮件地址。我正在使用我创建的服务帐户通过 API 进行身份验证,并已授予该服务帐户对团队驱动器和域范围委派权限的完全访问权限。下面是我的代码。谁能给点建议?
require 'google/apis/drive_v3'
require 'googleauth'
SCOPES = [
Google::Apis::DriveV3::AUTH_DRIVE,
Google::Apis::DriveV3::AUTH_DRIVE_APPDATA,
Google::Apis::DriveV3::AUTH_DRIVE_FILE,
Google::Apis::DriveV3::AUTH_DRIVE_METADATA,
Google::Apis::DriveV3::AUTH_DRIVE_METADATA_READONLY,
Google::Apis::DriveV3::AUTH_DRIVE_PHOTOS_READONLY,
Google::Apis::DriveV3::AUTH_DRIVE_READONLY
]
ENV['GOOGLE_APPLICATION_CREDENTIALS'] = "/path/to/my/service/account/creds.json"
service = Google::Apis::DriveV3::DriveService.new
service.authorization = Google::Auth.get_application_default(SCOPES)
response = service.list_files(
q: "'team drive id' in parents",
include_team_drive_items: true,
supports_team_drives: true
)
编辑:
响应对象如下:
#<Google::Apis::DriveV3::FileList:<memory location> @files=[#<Google::Apis::DriveV3::File:<memory location> @capabilities=#<Google::Apis::DriveV3::File::Capabilities:<memory location> @can_add_children=false, @can_change_viewers_can_copy_content=true, @can_comment=true, @can_copy=true, @can_delete=true, @can_download=true, @can_edit=true, @can_list_children=false, @can_move_item_into_team_drive=true, @can_move_team_drive_item=true, @can_read_revisions=true, @can_read_team_drive=true, @can_remove_children=false, @can_rename=true, @can_share=true, @can_trash=true, @can_untrash=true>, @created_time=<created time>, @explicitly_trashed=false, @has_augmented_permissions=true, @has_thumbnail=true, @icon_link=<icon link>, @id=<id>, @is_app_authorized=false, @kind=\"drive#file\", @last_modifying_user=#<Google::Apis::DriveV3::User:<memory location> @display_name=<display name>, @kind=\"drive#user\", @me=false, @permission_id=<permission id>, @photo_link=<photo link>>, @mime_type=<mime type>, @modified_by_me=false, @modified_time=<modified time>, @name=<name>, @parents=[<parent id>], @quota_bytes_used=0, @spaces=[\"drive\"], @starred=false, @team_drive_id=<team drive id>, @thumbnail_link=<thumbnail link>, @thumbnail_version=<thumbnail version>, @trashed=false, @version=<version>, @viewed_by_me=false, @viewers_can_copy_content=true, @web_view_link=<web view link>], @incomplete_search=false, @kind=\"drive#fileList\">
【问题讨论】:
标签: google-drive-api