Updated ggsrun to v122

ggsrun was updated to v.1.2.2

  1. For Google Docs (spreadsheet, document, slide and drawing), since I noticed that the revision files would not be able to be retrieved using Drive API v3, I modified this using new workaround.
    • The new workaround is to use Drive API v2. drive.revisions.get of Drive API v2 can retrieve not only the revision list, but also the export links. I thought of the use of the export links. This became the new workaround.
    • For the files except for Google Docs, the revision files can be retrieved using Drive API v3.
    • The usage is here.

I don’t know when this workaround will not be able to be used. But if this could not be used, I would like to investigate of other method.

(NEW) Retrieve old revision file from Google Drive

This method was updated at July 12, 2017.

In order to use this, at first, please retrieve your access token and enable Drive API.

1. File ID

Retrieve file id from file name.

curl -X GET -sSL \
    -H 'Authorization: Bearer ### Access token ###' \
    'https://www.googleapis.com/drive/v3/files?q=name="### FileName ###"&fields=files(id,name)'

Reference : https://developers.google.com/drive/v3/reference/files/list

2. Revision ID

Retrieve revision id from file id.

curl -X GET -sSL \
    -H 'Authorization: Bearer ### Access token ###' \
    'https://www.googleapis.com/drive/v3/files/### FileID ###/revisions?fields=revisions(id%2CmodifiedTime)'

Reference : https://developers.google.com/drive/v3/reference/revisions/list

Pseudo Browser with Google Spreadsheet

Gist

Overview

This is a sample script for creating the pseudo browser using Google Spreadsheet.

Description

I unexpectedly noticed this. I think that this is for off-line browsing using HTML data. So there are many limitations. At first, please confirm them.

  • Limitations
    • It cannot move from opened site to other outside site. If the outer site is opened as a new wind, your own browser is opened and move there.
    • For URL, it can move directories which is one low. But it cannot move directories more than two deeper.
      • Because it retrieves the HTML data from the inputted URL using UrlFetchApp. It cannot move to the out side of data retrieved by UrlFetchApp.
    • The access to the site opened by inputting URL is run at Google side.
    • Javascript on the opened site is run at your local PC side.
    • User-Agent cannot be changed from Mozilla/5.0 (compatible; Google-Apps-Script).

What I thought the interesting is that the appearance of the site has been maintained at this pseudo browser. And, by using this, the sites which are slow speed at your environment might be able to be opened smoothly.

Downloading Files From Google Drive Under No Authorization Using Browser

Gist

This is a sample script for downloading files from Google Drive under no authorization using browser. By using this sample, you can make other users download files from your Google Drive. Even if the other users are not Google users, they can download the files.

Demo

Downloading Files From Google Drive Under No Authorization Using Browser

This is a demonstration for downloading files from Google Drive under no authorization using browser. From the top document, You can see that an user who is not owner of Google Drive is downloading files.

Updated: GAS Library - ImgApp

ImgApp was updated to v1.1.0. New method was added.

2. doResize()

Overview

This method is for resizing images.

Description

Unfortunately, there are no methods to resize images at Google Apps Script. As a workaround, there is a method that it imports the image in Google Document and resizes the image using setWidth() and setHeight(). But in this method, the resized blob cannot be retrieved. So although I had thought of other workaround, I had not been able to find it. Recently, I accidentally discovered the other workaround doResize(). Since it was found that this workaround can be surely used, I added this to ImgApp.

GAS Library - ImgApp - getSize()

1. getSize()

Overview

This method is for retrieving the width and height of image as the unit of pixel.

Description

Unfortunately, there are no methods to directly retrieve the image size at Google Apps Script. As a workaround, there is a method that it imports the image in Google Document and retrieves the size using getWidth() and getHeight(). But in this method, it uses much time and resources on Google. So I thought of retrieving the information of image at the binary level, and created this. By this, the low process cost could be achieved.

Sublime Text Plugin - gislacks

Overview

This is a plugin of Sublime Text 3 for submitting files to both Gist and Slack.

Description

I like to use Sublime Text for developing scripts. And when I discuss about developing scripts, I often use Slack. When I submitted a script to Slack, I had saved the script to Gist as a backup. I had done manually this on my browser. Namely, I wanted to be saving the revision of script while I’m discussing about the script at Slack. One day, I wished this process had been able to be automatically run. So I created this plugin and gislack of a CLI tool.

CLI Tool - gislack

Overview

This is a CLI tool to submit files to both Gist and Slack.

Description

When I discuss about developing scripts, I often use Slack. When I submitted a script to Slack, I had saved the script to Gist as a backup. I had done manually this on my browser. Namely, I wanted to be saving the revision of script while I’m discussing about the script at Slack. Recently, I wished this process had been able to be automatically run. So I created this tool.

Go Library - getcode

Overview

This is a Golang library to automatically get an authorization code for retrieving access token using OAuth2.

Description

When it retrieves an access token and refresh token using OAuth2, the code for retrieving them has to be got by authorization on own browser. In order to retrieve the code, in generally, users have to click the authorization button and copy the code on the browser. This library can be automatically got the code by launching HTML server as a redirected server. At first, I have used this for retrieving the code from Google. But recently I noticed that this can be used for other sites. They are Google, GitHub, Slack and so on. This library can be used for creating such applications.