OneDrive to Google Cloud Storage

Transfer files from Microsoft OneDrive to Google Cloud Storage.


People who wants to transfer files from Microsoft OneDrive to Google Cloud Storage

The Need

OneDrive gives free storage for a limited time, for example if you buy a new Samsung phone, OneDrive will give you additional 100GB free storage for 2 years. And Samsung Gallery backups your Camera photos to OneDrive. For 2 years, everything is awesome with that 100 GB free storage. But when the free storage expires, you are left with only 15 GB storage, Samsung Gallery and Microsoft bombards you with the alerts to upgrade your account.

You are left with 3 choices:

  • upgrade your account,
  • delete your files,
  • transfer your files to another storage option

I wanted to transfer my files to Google Cloud Storage, because it is cheap and accessible for archival needs.

How to Configure

You should provide necessary data as environment variables. You can provide environment variables in a .env file.

  • Copy .env.example to .env
  • Fill the variables in .env

Explainations of Environment Variables


Access token to be able to access OneDrive API. You can get it by following:

  • visit Graph Explorer,
  • Sign in to your Microsoft Account from left side,
  • There will be a tab called Access Token , click that tab, your access token will appear.

Simply copy that token and past it to .env file as ONE_DRIVE_ACCESS_TOKEN variable.


Name of the Google Cloud Storage bucket. Make sure that there is a bucket of that name, if not, go to Google Cloud Console and create a bucket of that name.


Id of your OneDrive drive. You can get it by following:

  • go to Graph Explorer and sign in,
  • request,
  • your drive id will appear in response as

Relative path of folder that has your files. For example if you want to transfer files which are located in OneDrive->Personal Files->Photos->Exciting Day, then you should provide ONE_DRIVE_FOLDER_RELATIVE_PATH=Personal Files/Photos/Exciting Day as environment variable.

Authenticate with Google Cloud

If you run the script in a Compute Engine which is located in the same project with the bucket, you won’t need to authenticate. But if you are outside of the Google Cloud, you should visit and follow the instructions to authenticate with Google Cloud.

How to Run

  • npm run build
  • npm run start

#cloud #onedrive #web-development #developer

Transfer Files from Microsoft OneDrive to Google Cloud Storage
13.55 GEEK