Robomotion
Search…
Google Packages Interaction
As Google documents said, a service account is a special type of Google account intended to represent a non-human user that needs to authenticate and be authorized to access data in Google APIs. You need to a service account and its json key to use Google packages. We will create it for Google Sheets package in this document.
  • Open the menu and click APIs & Services -> Library.
  • Search for Google Sheets API. Note that if you want to use Create Spreadsheet node you will need Google Drive API so I will add Google Drive too.
  • After click the open Google Sheets API, click the enable.
  • After enabling api, it will redirect you to the overview page of Google Sheets API then click to credentials.
  • Click the Create Credentials . Then select the service account .
  • Follow this 3 steps to create your service account. I added my service account as editor of this project.
  • Click to your newly created service account.
  • Go to Keys and click the create new key.
  • Key type must be JSON and after creating, it will download a file that contains required informations about the service account.
  • You can go to your flow designer for adding the content of the downloaded file, if you don’t have a vault you should go to Vaults in designer to create one.
  • Press the top right + sign to create a new vault, than enter the name and description information for the new vault.
  • When you press create your new vault will be created and you will see a popup dialog. This is the Vault Secret Key that is generated in your browser and used to encrypt the generated master key for your vault. In order to open a vault you have to provide two things: One that you know, that is the password for your account and one that you have and that is the Vault Secret Key. Vault Secret Key is never sent to Robomotion servers so if you lose it there is no way to open a vault. Keep it safe and secure!
  • After creating a vault, you can open it and add vault items. Create a document item.
  • Open the file that you downloaded for key and copy the content then add it to content of vault item then save it.

Reading a Spreadsheet

  • I will add my service account as an editor to a spreadsheet because it needs access to a spreadsheet like a regular account.
  • Open Spreadsheet node needs an url of a spreadsheet that service account has access and credentials. I added url and my service account’s vault item.
  • Get Range node will read all used range of this spreadsheet so I just selected Headers for take the first row as Headers and other properties are default.
  • It’s asking for a vault secret key when I run my flow because I just created my vault.
  • That’s it, you can see the output of Get Range node. Congratulations!

Creating a Spreadsheet

  • We need to use Google Drive API too for using Create Spreadsheet node because when we create a spreadsheet it is a private document for our service account and we need to share this document with our main account or any other accounts.
  • I will add a function node for defining accounts that will be shared with.
  • I will add my service account to Credentials of Create Spreadsheet and add a document title to Title field.
  • That's it you can take the id of your newly created spreadsheet from output of the Create Spreadsheet node and to view your spreadsheet the url must be: https://docs.google.com/spreadsheets/d/your_spreadsheet_id/
  • Since I added my account as a reader newly created spreadsheet is read-only for me.

Downloading a File - Google Drive

  • We need to share a folder or a file in drive which we want to download file from. I will share a folder with the service account and the service account will be editor of this folder.
  • I have a sample txt file in that folder and I need to its id for downloading. Just right click the file and click the get link then you can take id from that url. Also you can use list folder node for taking the id.
  • After adding the service account to Connect node and giving id of file and download path in my local to Download File node it will be ready to use.
Last modified 26d ago