1

I did authentication with the following code:

  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!

and created the file using

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'})

The document is created successfully, but I can not figure out how to set the resulting file's ownership to a specific user within my domain (or share it with another user if setting ownership is not possible).

Ali Afshar
  • 40,967
  • 12
  • 95
  • 109
Steve Wilhelm
  • 6,200
  • 2
  • 32
  • 36

1 Answers1

2

You need to use the permissions feed to add permissions. See the document on sharing, and the drive.permissions.insert method, which has a Ruby example:

Ali Afshar
  • 40,967
  • 12
  • 95
  • 109