Try Something New
Try Something New

Reputation: 11

How can I get the userid of google account for data transfer api?

I want to transfer data from one google account to another before deleting the google account . I came across data transfer api in admin sdk . I need to send olduserid and newuserid in request body . I dont know where to find it . can someone help me with this ?

Upvotes: 0

Views: 376

Answers (1)

Juan Serrano
Juan Serrano

Reputation: 379

It's unfortunate that I didn't come across this question earlier, but I will provide all the most relevant information in case someone has the same question in the future.

To make a data transfer with the Admin SDK Data Transfer API we will use 2-3 methods from 2 different APIs:

Note: you may use the API explorer available in the documentation of the API to test the output and parameters of the API before you implement them into a solution. Keep in mind that all actions taken in the API Explorer will have real consequences in your domain. It is highly suggested you experiment with test accounts before you affect users in production.

I will now provide a sort of pseudocode that shows the flow of data and API calls your application will make:

  1. Obtain the userId of the source and destination of the data transfer with Users.get, using these parameters:
"userKey": "[email protected]",
"fields": "primaryEmail,id"

Will result in this server response:

{
  "id": "108020532870171195535",
  "primaryEmail": "[email protected]"
}

You will run this twice to obtain both oldOwnerUserId and the newOwnerUserId values we will use to construct the data transfer in the next call.

  1. Call the Transfers.insert method with the following request body:
{
  "oldOwnerUserId": "#####################",
  "newOwnerUserId": "#####################",
  "applicationDataTransfers": [
    {
      "applicationId": 55656082996,
      "applicationTransferParams": [
        {
          "key": "PRIVACY_LEVEL",
          "value": [
            "SHARED",
            "PRIVATE"
          ]
        }
      ]
    },
    {
      "applicationId": 810260081642,
      "applicationTransferParams": [
        {
          "key": "PRIVACY_LEVEL",
          "value": [
            "SHARED",
            "PRIVATE"
          ]
        }
      ]
    }
  ]
}

In my example the data transfer created transfers data from applicationId: 55656082996 (Google Drive) & applicationId: 810260081642 (Google Data Studio). These are not the only supported Google services, you can find the rest by calling the Applications.list method.

At this time the Data Transfer API supports transferring data from the following services between users in the same organization:

  • Google Currents (553547912911)
  • Google Calendar (435070579839)
  • Google Data Studio (810260081642)
  • Drive and Docs (55656082996)

In case you are wondering, other types of data can be transferred between Google Workspace users as outlined in this Help Center article https://support.google.com/a/answer/1041297.

Upvotes: 1

Related Questions