1

次のコードで認証を行いました。

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

ドキュメントは正常に作成されましたが、結果のファイルの所有権をドメイン内の特定のユーザーに設定する方法がわかりません (所有権を設定できない場合は別のユーザーと共有します)。

4

1 に答える 1

2

アクセス許可を追加するには、アクセス許可フィードを使用する必要があります。共有に関するドキュメントdrive.permissions.insert、Ruby の例を含むメソッドを参照してください。

于 2013-01-08T01:21:11.010 に答える