Ruby 如何使用Web服务OAuth凭据对使用files.insert创建的文件设置权限?

Ruby 如何使用Web服务OAuth凭据对使用files.insert创建的文件设置权限?,ruby,google-drive-api,google-api-ruby-client,Ruby,Google Drive Api,Google Api Ruby Client,我使用以下代码进行了身份验证: key = Google::APIClient::KeyUtils.load_from_pkcs12(path_to_key_file, 'notasecret') @client.authorization = Signet::OAuth2::Client.new( :token_credential_uri => 'https://accounts.google.com/o/oauth2/token', :audience

我使用以下代码进行了身份验证:

  key = Google::APIClient::KeyUtils.load_from_pkcs12(path_to_key_file, 'notasecret')
  @client.authorization = Signet::OAuth2::Client.new(
      :token_credential_uri => 'https://accounts.google.com/o/oauth2/token',
      :audience => 'https://accounts.google.com/o/oauth2/token',
      :scope => 'https://www.googleapis.com/auth/drive',
      :issuer => 'xxx@developer.gserviceaccount.com',   
      :signing_key => key)

    @client.authorization.fetch_access_token!
并使用

file = @drive.files.insert.request_schema.new({
  'title' => title,
  'description' => description,
  'mimeType' => mime_type
})
media = Google::APIClient::UploadIO.new(file_name, mime_type)
result = @client.execute(
  :api_method => @drive.files.insert,
  :body_object => file,
  :media => media,
  :parameters => {
    'uploadType' => 'multipart',
    'convert' => true,
    'alt' => 'json'})

文档已成功创建,但我无法确定如何将结果文件的所有权设置为我域中的特定用户(如果无法设置所有权,则与其他用户共享)。

您需要使用权限提要添加权限。请参阅和方法,其中有一个Ruby示例: