I'm writing a piece of code in Ruby for making data transfers using Google Data Transfer API. I specifically mean this
The code I have is as follows:
idOldUser = "116170568974079979335"
idNewUser = "105318746921076261308"
atp = Google::Apis::AdminDatatransferV1::ApplicationTransferParam.new(
key: "PRIVACY_LEVEL",
value: ["PRIVATE", "SHARED"])
appid = 435070579839
adt = Google::Apis::AdminDatatransferV1::ApplicationDataTransfer.new(
application_id: appid,
application_transfer_params: [atp])
dt = Google::Apis::AdminDatatransferV1::DataTransfer.new(
kind: "admin#datatransfer#DataTransfer",
old_owner_user_id: idOldUser,
new_owner_user_id: idNewUser,
application_data_transfers: [adt])
service = Google::Apis::AdminDatatransferV1::DataTransferService.new
service.insert_transfer(dt)
When I execute it, the following error appears:
/var/lib/gems/2.4.0/gems/google-api-client-0.23.4/lib/google/apis/core/http_command.rb:212:in `check_status': Unauthorized (Google::Apis::AuthorizationError)
from /var/lib/gems/2.4.0/gems/google-api-client-0.23.4/lib/google/apis/core/api_command.rb:118:in `check_status'
from /var/lib/gems/2.4.0/gems/google-api-client-0.23.4/lib/google/apis/core/http_command.rb:183:in `process_response'
I've also tried to execute it from API Explorer. The following JSON returns a HTTP 200. Some minutes after that, I see in the new user's inbox a mail saying that the transfer is completed. Then I see in Calendar app an entry called "Transfered from user". However, it appears empty.
{
"oldOwnerUserId": "116170568974079979335",
"newOwnerUserId": "105318746921076261308",
"kind": "admin#datatransfer#DataTransfer",
"applicationDataTransfers": [
{
"applicationId": "435070579839",
"applicationTransferParams": [
{
"key": "PRIVACY_LEVEL",
"value": [
"PRIVATE",
"SHARED"
]
}
]
}
]
}
I have used this scope: https://www.googleapis.com/auth/admin.datatransfer
And curiously, the other methods of that library, such as list_applications, work for me. The only problem is with insert_transfer .
Can you help me to make this data transfer working? If it's possible with Ruby, great.
Thank you in advance.